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:
using memory inside alternation

 



princepawn
Novice

Dec 3, 2000, 10:33 PM

Post #1 of 3 (1504 views)
using memory inside alternation Can't Post

my $numre = '((<LI>)?(D)|(<LI>)?(F)(\d+)?)';

my $t= '*F2';

if ($t =~ $numre) {
warn "$1.$2.$3.$4";
}

for some reason, I dont have anything is $2,$3, or $4 even though I have parentheses around those elements of the pattern.

How can I store the parts of the match in $2,$3,$4?

Thanks.



princepawn
Novice

Dec 3, 2000, 10:41 PM

Post #2 of 3 (1504 views)
Re: using memory inside alternation [In reply to] Can't Post

Well, I figured out my own question:

<pre>
my $intre = '(<LI>)?(D)';
my $flore = '(<LI>)?(F)(\d+)?';
my $numre = '($intre|$flore)';

my $t= '*F2';

if ($t =~ /$intre/ or $t =~ /$flore/) {l
warn "$1.$2.$3.$4";
}
</pre>
But would appreciate some input on
1- why what I did failed
2- how to get source code formatted as pre-formatted text


japhy
Enthusiast / Moderator

Dec 6, 2000, 8:48 AM

Post #3 of 3 (1504 views)
Re: using memory inside alternation [In reply to] Can't Post

You use UBB tags, which are like HTML, but with brackets [ and ] instead of carets < and >. Use &#91;code&#93; and &#91;/code&#93; around your text.

------------------
Jeff "japhy" Pinyan -- accomplished author, consultant, hacker, and teacher


 
 


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

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