3 ms·
I thought java regexes had comments? https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/regex/Pattern.html#COMMENTS https://docs.oracle.com
by throwaway_pdp09 6y ago
I thought java regexes had comments?
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/regex/Pattern.html#COMMENTS https://docs.oracle.com/en/java/javase/11/docs/api/java.base...
- justin_oaks 6y agoHuh, I didn't know that. I've read through a fair amount of Java code with regexes and never seen anyone use comments. Maybe it's because Java doesn't have proper multi-line string support built into the language. If you don't have multi-line support in the language then you're more likely to put the comments outside the string: String regex= "^" +"(?:http)(?:s)?" // http or https +"(?:\:\/\/)" // :// +"(?:www\.)?" // optional www. +"(?:[^\ ]*)" // rest of URL (no spaces) +"$";
- throwaway_pdp09 6y ago... which has to be a better way of doing it (comments + regexps in digestible chunks) than having a rather wordy library.