in reply to /x on regexes in Perl6?
But deep down, I have a problem with the fact the following regex won't match if the /x modifier is on by default:
I admit that new users already have to become aware of many special regex metacharacters. I just think that using the space character as a metacharacter is perhaps non-intuitive.$str = 'Hello World!'; # This will NOT match in Perl6? print 'Matched' if $str =~ /Hello World/;
I agree that the pattern /Hello\s+World/ is usually more "correct". But the pattern /Hello World/ is often perfectly usable, and it's also much easier to understand. In my humble opinion, anything which makes a simple "Hello World" example fail gives a programming language a steeper learning curve.
buckaduck
|
|---|