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:
Help with REG EXP Perl Code basic question

 



GuerillaSquad
Novice

Aug 31, 2009, 11:16 AM

Post #1 of 3 (3459 views)
Help with REG EXP Perl Code basic question Can't Post

I have a piece of PERL code. I know what the code does but I cannot figure out in any documentation the usage. I will put the short code line here and then ask my question...

s#<(/?)H1>#<$1H2>#g;

Q. What does the /? do?

I know the () are tagging so I can call $1 later, and I can figure out the /? is saying anything before "H1", but how is it saying that?

Thanks,
Mike


---------------------------
~The path to perfection is never clear~


KevinR
Veteran


Aug 31, 2009, 11:47 AM

Post #2 of 3 (3457 views)
Re: [MikeDexter] Help with REG EXP Perl Code basic question [In reply to] Can't Post

In that context the "?" is a quantifier meaning "zero or one" so it means if there are zero or one forward slashes "/?" the match is true. It will match the opening and closing H1 html tags:

<H1>
</H1>

Its turning all H1 tags into H2 tags.
-------------------------------------------------


GuerillaSquad
Novice

Aug 31, 2009, 11:52 AM

Post #3 of 3 (3454 views)
Re: [KevinR] Help with REG EXP Perl Code basic question [In reply to] Can't Post

KevinR,

Very Clever.

I was not thinking about the closing tag preservation. Thanks for the response.

Mike


---------------------------
~The path to perfection is never clear~

 
 


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

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