3 ms·
Huh, 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 prop
by justin_oaks 6y ago
Huh, 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.