Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class Main {
- public static void main(String[] args) {
- String regex = "(a*)*b";
- String haystack = "a";
- for( int i = 1;i < 30; i++ ){
- long start = System.nanoTime();
- Pattern pattern = Pattern.compile( regex );
- Matcher matcher = pattern.matcher( haystack );
- matcher.find();
- long end = System.nanoTime();
- System.out.println("On " + haystack + ", .find run in " + (end - start) + " nanoseconds.");
- haystack = haystack + "a";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment