Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Pattern matching

Posted on 2006-03-24
3
Medium Priority
?
358 Views
Last Modified: 2011-10-03
Hi all,

How do I check if $from_mail is like:
[A-Za-z]([A-Za-z0-9]+)[0-9]"@mysite.com"
?

Comments: the check is performed after I know $from_mail looks like a correct e-mail address.
So I want to know if it starts with a letter, then alphanumeric chars, then a digit, then "@mysite.com".

The code should look like:
.......
.......
.......
if (cond):
   echo '<strong>Pattern matched!</strong><br>';
else:
   echo '<strong>Pattern did NOT match!</strong><br>';
endif;

Thanks!
0
Comment
Question by:slavikn
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
Tomeeboy earned 140 total points
ID: 16280484
If that's the regex you want to match, then you can use preg_match:
http://us2.php.net/preg_match
0
 
LVL 15

Expert Comment

by:Tomeeboy
ID: 16280536

preg_match("/[A-Za-z]([A-Za-z0-9]+)[0-9]@mysite.com/", $matches);
if (isset($matches[0])) {
    echo "Pattern Matched";
} else {
    echo "Pattern NOT Matched";
}
0
 
LVL 1

Author Comment

by:slavikn
ID: 16280989
Thanks for your quick reply!!  (p.s. sorry for only 35 points - I have no points left at all :-()
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month20 days, 21 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question