Created
October 11, 2017 22:48
-
-
Save jonasbits/782ab527e71bb67bd83a3b4d627e3e79 to your computer and use it in GitHub Desktop.
Inverse regex to match non .bit urls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//compile with 'javac RegexTest.java' | |
//run with java RegexTest example.com | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class RegexTest { | |
public static void main(String[] args) { | |
//line bellow does not work, must include regex inline instead | |
// String regex = "((\\S+)\\s*some\\s*"; | |
Pattern pattern = Pattern.compile("(?!([^\\/])+\\.bit[\\/\\s]?.*).*"); | |
for (int i = 0; i < args.length; ++i) { | |
Matcher matcher = pattern.matcher(args[i]); | |
System.out.println("'" + args[i] + "' does " + (matcher.matches() ? "" : "not ") + "match '" + "inlineRegEx as non .bit url" +"'"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment