Thread: Regex examples
View Single Post
Old 10-12-2020, 08:19 PM   #680
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 47,092
Karma: 169815798
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by hobnail View Post
So why did my extra parentheses screw it up?

I added the parentheses so that it was clear, to me at least, what the OR was for.
In regex, parentheses are special characters. That's why you end up needing to escape a literal parenthesis with a \, (text) is capturing parentheses unless you start the text inside the parentheses with a ?: i.e. (?:text) for non-capturing parentheses. I seem to remember a 4th variety of parentheses but not sure about what flavour of regex that was in.

Basically, you can't use them as separators as you would in a mathematical expression.
DNSB is offline   Reply With Quote