Need help for a regex

B

brunomartin88

Hi RegEx masters,

I use this expression
<@LINK=[^(@>)]*@>.*?</@link@/>
to parse a text containing something like :

<@LINK=www.google.com@>MyLink</@link@/>

So, for the this text the REGEX parser returns 1 match.
Now, i try tp parse a text containing something like :

<@LINK=mailto:[email protected]@>MyLink</@link@/>

My REGEX parser does not match anything because of the @ in the email
address : (e-mail address removed)

I want to modify my expression (<@LINK=[^(@>)]*@>.*?</@link@/>) to
include this case so the REGEX parser would return 1 match.

Have ideas ???
 
P

Paul Lalli

Hi RegEx masters,

I use this expression
<@LINK=[^(@>)]*@>.*?</@LINK@/>
to parse a text containing something like :

<@LINK=www.google.com@>MyLink</@LINK@/>
So, for the this text the REGEX parser returns 1 match.

I don't believe you.

#!/usr/bin/perl
use strict;
use warnings;

$_ = '<@LINK=www.google.com@>MyLink</@link@/>';
if (m{<@LINK=[^(@>)]*@>.*?</@link@/>}){
print "Found: $1\n";
} else {
print "Not found\n";
}

__END__
Possible unintended interpolation of @link in string at ./clpm.pl line
6.
Possible unintended interpolation of @link in string at ./clpm.pl line
6.
Global symbol "@link" requires explicit package name at ./clpm.pl line
6.
Global symbol "@link" requires explicit package name at ./clpm.pl line
6.
Execution of ./clpm.pl aborted due to compilation errors.

If I comment out use strict and use warnings, like I suspect you have,
I get:
Not found

You have at least 2 distinct problems with that regexp. You're not
escaping the @ symbol when what follows looks like a variable name, and
you're not using character classes correctly. [^(@>)] means to match
any character that is not a left parenthesis, an at sign, a greater
than, or a right parenthesis. It does not mean "any string that is not
the two-character string '@>'", as I suspect you think it means.

Please read the posting guidelines for this group, and then post a
short-but-complete program that demonstrates what you regard as a
successful execution, and then the corresponding program that fails for
your modified data.

Paul Lalli
 
T

Tad McClellan

Hi RegEx masters,


Some of us are _Perl_ regex masters.

I use this expression
<@LINK=[^(@>)]*@>.*?</@LINK@/>


But that is not a Perl regex!

Have ideas ???


Ask questions about Perl in the Perl newsgroup, ask questions about
other languages in other newsgroups (or, translate from your other
language to Perl in your posting, and then translate the Perl
answer back into the other language).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,616
Members
45,306
Latest member
TeddyWeath

Latest Threads

Top