PHP: preg_match - Unknown Modifier Error although using correct Regular Expression
Question by Guest | 2014-03-12 at 18:20
Although I am using a correct regular expression in my PHP script, I am always getting the following error:
Warning: preg_match() [function.preg-match]: Unknown modifier '@'
I am using the following call of the function:
preg_match("^[^@]+@[^@]+$", $str)
Unfortunately, I cannot even imagine where the error is hidden in this line! In all of the other programs, I have tried this RegEx, it is working like a charm! Can someone help me?
Related Topics
Lazarus: Program without GUI - Many WSRegister Errors
Question | 6 Answers
How to Replace multiple Texts at the same Time
Tutorial | 0 Comments
HTACCESS: Simplify URL
Tutorial | 0 Comments
Create Custom Error Pages for Website
Tip | 0 Comments
Delphi: Global Treatment of Errors (Exceptions)
Tutorial | 0 Comments
PHP: Check Strings with Ctype-Functions for Character Classes
Article | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
You have to surround your regular expression with a delimiter. Possible delimiters are "/", "~" or "#", for example.
It should work this way:
In principle, you can use each character as the delimiter that is not alphanumeric. Also a backslash or whitespace is not allowed.
Within your regular expression, you used delimiter has to be escaped. That is why, you should preferably use a delimiter that is not occurring within your regular expression.
Modifier for your regular expression can be written behind the delimiter:
More information you can get on the official PHP page.
2014-03-13 at 21:31