Reputation: 11901
What is the easiest way to construct a java regular expression and pass it to a method that expects a String? Ideally something similar to SO JavaScript solution here.
System.out.println(System.getProperty(/* Regex here*/));
Upvotes: 1
Views: 2834
Reputation: 1074088
What is the easiest way to construct a java regular expression and pass it to a method that expects a String?
You can't. You can only use regular expressions with methods that are written to accept them, you can't use them with any method that just accepts a string (such as System.getProperty
).
Methods accepting regular expressions, either explicitly as Pattern
instances or implicitly as strings (like String#replaceAll
), will say clearly that they do in their JavaDoc.
Upvotes: 1