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:
Matching On Metacharacters

 



Eric
New User

Jun 24, 2002, 6:40 PM

Post #1 of 6 (5141 views)
Matching On Metacharacters Can't Post

 I need some assistance in matching on Metacharacters to reject any e-mails which may contain these WITHIN the boundaries marked with an X below (am already filtering at the X parts with other expressions and this is working fine). Except for a "." (period).

XsomenameX@Xsome.domainX.TLD

I'd also like to match any commas, dollar signs or forward slashes, etc., but not sure if I need to 'escape' all of the characters or just the metacharacters within a [] format like: [~!@#%=;:'"<>,\+\?\*\^\$\[\]\{\}\|\\] and in two separate matches:

1. Between the 1st character (X) and the last character (X)of whatever preceeds the "@".

Like: $email !~ m/XmetamatchhereonlyX@/

2. Between the 1st character (X) and the last character (X)of whatever follows the "@" and preceeds any final "." just before the TLD extension.

And: $email !~ m/\@XmetamatchhereonlyX\.[A-Za-z]{2,4}$/>

WHEW!!! Thanks for any help.

Eric


Eric
New User

Jun 24, 2002, 6:47 PM

Post #2 of 6 (5138 views)
Re: [Eric] Matching On Metacharacters [In reply to] Can't Post

I forgot to mention that I can NOT do that match using a word boundary, because observations have been some addresses are entered like:

so meje rk@bo gus.tld

I'm already bouncing back those with white spaces in an earlier match :-)

The trick is trying to figure out how to perform the match starting with the 2nd character through the next to last character BEFORE the @ in the first case, and then a separate match starting with the 2nd character after the @ through the next to last character BEFORE the (or any) Final "." just before the ending TLD (which is why I used a $ anchor in the 2nd expample posted).

Eric


Jasmine
Administrator

Jun 26, 2002, 10:53 AM

Post #3 of 6 (5131 views)
Re: [Eric] Matching On Metacharacters [In reply to] Can't Post

If you're just looking for email validity, check out the [url=http://search.cpan.org/search?dist=Email-Valid]Email::Valid module.


Eric
New User

Jun 28, 2002, 12:25 AM

Post #4 of 6 (5126 views)
Re: [Jasmine] Matching On Metacharacters [In reply to] Can't Post

Tnx for the tip, Jasmine...I'll go take a look. The Metacharacter match Regexp would finalize the rest of what is working pretty well if you can shed any light, however.

Regards,

Eric


Paul
Enthusiast

Jul 15, 2002, 5:17 PM

Post #5 of 6 (5108 views)
Re: [Eric] Matching On Metacharacters [In reply to] Can't Post

I'm not 100% sure on what you are asking but if you are wanting to match meta characters you should use \Q \E in your regex to escape them...eg...

if ($something =~ /^\Qmy.name@domain.com\E$/) {


mahesh18
New User

Dec 2, 2002, 10:59 PM

Post #6 of 6 (5020 views)
Re: [Paul] Matching On Metacharacters [In reply to] Can't Post

hi Paul,
the answer that u have given about "Matching On Metacharacters" has gave a lot help to me in my project.
thanx a lot for it as u share ur knowledge with all of us.


regards/mahesh

 
 


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

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