Assumptions:
#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11158577 use warnings; for ( split /\n/, <<END ) #foo bli bla bli #foo bar baz #more than #one is a #string more than #one is a #string foo bli bla # does not match # END { /(?|#(\S+)|()\z)/ and print "found '$1' in '$_'\n"; }
Outputs:
found 'foo' in '#foo bli bla' found 'foo' in 'bli #foo bar baz' found 'more' in '#more than #one is a #string' found 'one' in 'more than #one is a #string' found '' in 'foo bli bla' found '' in '# does not match #'
In reply to Re: Simple Regex drives me insane
by tybalt89
in thread Simple Regex drives me insane
by cheerydog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |