Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String Regular Expressions

Status
Not open for further replies.

timgerr

IS-IT--Management
Joined
Jan 22, 2004
Messages
364
Location
US
Hey all, I have a question for ya, Can I string together regular expressions?

Here is what I mean, lets say that I want to search for a valid email address that is 5 characters. Now I think that the email address would look like this
Code:
\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b
and I would also want to make sure the email address is nore more than 25 characters. Can this be done with the same regular expression?

Thanks,
-T

-How important does a person have to be before they are considered assassinated instead of just murdered?
-Need more cow bell!!!

 
valid email address that is 5 characters
5 chars total?
5@5.5 which would be 15.

length ($emailAddress) for your last question.
 
yea but I was wondering if I could search for email address and no more than 5 characters within one regular expression

-How important does a person have to be before they are considered assassinated instead of just murdered?
-Need more cow bell!!!

 
I'm still not following; are you looking for the first 5 chars of an e-mail address? if so, substrings are what ur looking for.
 
Sorry, Here is what I am looking for. I want to search for an email address that contains no more than 25 characters.

-T

-How important does a person have to be before they are considered assassinated instead of just murdered?
-Need more cow bell!!!

 
k, u don't necessarily needs regEx for that, just use the length funciton i.e

@emailArray = qw (data in here);
foreach $emailAddress (sort @emailArray) {
print "$emailAddress is gt > 25 chars\n" if length($emailAddress > 25);

This is not tested of course.
 
Max1x, thanks for the useful information. I know that I can do this by using other means, I was wondering if I could string multiple regular expressions to qualify a string.

Can it be done, if so are there any examples.

Thanks for the help,

-T

-How important does a person have to be before they are considered assassinated instead of just murdered?
-Need more cow bell!!!

 
Yes. for ex:
/()/i
$1 would represent whatever is inside the (); it could be you entire concatanated RegEx.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top