in reply to Re^3: regex to collect local links in Markdown
in thread regex to collect local links in Markdown
my $text = "Hello, I am a [Perl Monk], still not good at [Regular Expr +essions]. I have been helped immensely by the good monks at [Perl Mon +ks](http://www.perlmonks.org). This is what I look like ![mymugshot]. + Thank you."; listlink($text); sub listlink { my ($text) = @_; my @links = ( $text =~ / (?<!\!\[) # make sure the match is not preceded by a ![ (?<=\[) # but is in fact preceded by just a [ .*? # the match (?=\]) # followed by a ] (?!\]\() # but not followed by a ( /xg ); foreach my $link (@links) { print "$link\n"; } } ####### Perl Monk Regular Expressions Perl Monks](http://www.perlmonks.org). This is what I look like ![mymu +gshot
Update: took out superfluous code.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: regex to collect local links in Markdown
by GrandFather (Saint) on Oct 27, 2007 at 20:13 UTC | |
by punkish (Priest) on Oct 27, 2007 at 20:23 UTC | |
by GrandFather (Saint) on Oct 27, 2007 at 20:27 UTC |