How do I match something like this using perl regex? -


the file looks like

[n computer end] [m whatever] [n look] [n why not] 

i need words in bracket start [n here want computer end why not may or may not in same line

i tried this:

if($line =~/\[n(.+?)\]/) 

but match first 1 of each line.

use g modifier on regular expression "g"lobal matches. either this:

while ($line =~ /\[n(.+?)\]/g) {     # $1 contains text between "[n" , "]" } 

or this:

my @matches = $line =~ /\[n(.+?)\]/g; # @matches contains of matching items of text 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -