in reply to Perl Regex

Edited about 30 secs after posting - the regex does not work.

Your regex is not delimited. Using the explicit match (m//) notation might help clarify things.

It also needs the g modifier to match all cases.

my $str = 'Link:1625 housing Link:2004'; my @matches = ( $str =~ m/(?:link:) [^\s\|]+/g );

See perlretut for more examples.

(I have not tested that the regex works, though).

Replies are listed 'Best First'.
Re^2: Perl Regex
by swl (Prior) on Nov 17, 2019 at 05:38 UTC

    Try this for the regex. It works with the test data provided.

    my @matches = ( $str =~ m/\|?Link:([\s0-9-]+)/g );