4 ms·
For everyone that doesn't see the point, take a look at the example of parsing a long string [0]. The verbal expression is _much_ easier to read than the regula
by jjevanoorschot 6y ago
For everyone that doesn't see the point, take a look at the example of parsing a long string [0]. The verbal expression is _much_ easier to read than the regular expression.
[0] https://github.com/VerbalExpressions/JavaVerbalExpressions/wiki/Parse-long-strings-example https://github.com/VerbalExpressions/JavaVerbalExpressions/w...
- pavon 6y agoI don't see it. The regex is mostly hard to read because they formatted it poorly and put in a bunch of unnecessary non-capturing groups. I find this to be just as easy (if not easier) to read as their first example: String pattern = ( "(\d+)\t"+ "(\d+)\t"+ "([0-1])\t"+ "(http://localhost:20\d{3})\t"+ "([0-1])\t"+ "(\d+)\t"+ "([0-1])\t"+ "(\d+)\t"+ "(\d+)\t"+ "([0-1])\t"+ "(\d+)\t"+ "(STR[0-2])" ); And this is just as easy to read as their second example: String num = "(\d+)\t"; String bool = "([0-1])\t"; String url = "(http://localhost:20\d{3})\t"; String str = "(STR[0-2])"; String pattern = num+num+bool+url+bool+num+bool+num+num+bool+num+str; And yes, I do frequently split up my regexes like that to make them more readable. The only improvement I see is that you don't have messy escaping in the url. That is genuinely nice. It motivates me to start using an regEsc() function instead of doing it by hand. However, I find "capt().endCapture()", and other verboseness to be a step backwards. Edit: Actually, from what I can tell, all the escaping was unnecessary in this case as well. Updated examples without unneeded escape characters.