CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
what does this regex do?

 



mszak50
New User

May 4, 2010, 4:10 PM

Post #1 of 3 (3008 views)
what does this regex do? Can't Post

 
I've been handed an old, more or less undocumented perl script, and I'm trying to figure out how this script works by examining input data and matching it up with the regex's used.

This particular regex is baffling me.

(\-searchResults|\-itm|record\-)

The data that I think it's supposed to match up on is

class=searchResults

What does the "-" operator mean in this context?


rovf
Veteran

May 5, 2010, 1:36 AM

Post #2 of 3 (2999 views)
Re: [mszak50] what does this regex do? [In reply to] Can't Post


Quote
What does the "-" operator mean in this context?


I am not aware that "-" has a special meaning in this context (it would do so only between [] brackets), and in any case it is escaped; so the regexp should be equivalent to

(-searchResults|-itm|record-)

so it should match "-searchResults", not "searchResults".


shawnhcorey
Enthusiast


May 5, 2010, 5:04 AM

Post #3 of 3 (2993 views)
Re: [mszak50] what does this regex do? [In reply to] Can't Post


In Reply To
I've been handed an old, more or less undocumented perl script, and I'm trying to figure out how this script works by examining input data and matching it up with the regex's used.

This particular regex is baffling me.

(\-searchResults|\-itm|record\-)

The data that I think it's supposed to match up on is

class=searchResults

What does the "-" operator mean in this context?


It means - (ASCII character 0x2D). A backslash in front of a non-word character escapes the character. For more information, see `perldoc -f quotemeta` and `perldoc perlre` and search for /\\Q/.

__END__

I love Perl; it's the only language where you can bless your thingy.

Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib.

Get Markup Help. Please note the markup tag of "code".

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives