What's the meaning of this perl regex expression? -


the regex expression below: if ($ftxt =~ m|/([^=]+)="(.+)"|o)    {     .....    } 

this regex seems different many other regex.what makes me confused "|" ,most regex use "/" instead of "|". , , group ([^=]+) makes me confused.i know [^=] means "the start of string" or "=",but mean repeat '^' 1 or more times? ,how explain this?

you can use different delimiters instead of /. instance use:

m#/([^=]+)="(.+)"#o 

or

m~/([^=]+)="(.+)"~o 

the advantage here of using different / don't have escape slashes, because otherwise, you'd have use:

m/\/([^=]+)="(.+)"/o   ^ 

[or [/]]

([^=]+) capture group, , inside, have [^=]+. [^=] negated class , match character not =.

^ behaves differently @ beginning of character class , not same ^ outside character class means 'beginning of line'.

as last part o, flag haven't met far little search brought me this post, quote:

the /o modifier in perlop documentation instead of perlre documentation since quote-like modifier rather regex modifier. has seemed odd me, that's how is.

before perl 5.6, perl recompile regex if variable had not changed. don't need anymore. use /o compile regex once despite further changes variable, other answers noted, qr// better that.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -