I am using the following regular expression to validate email addresses in my application (Angular 2).   ^[a-zA-Z0-9.!#$%&amp;'+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)$  The validation works fine, however, its failing for email addresses that contain more than one '@' symbol (which should be invalid). e.g.  The following emails pass the check (when they should fail):  john@subaru@ferrari.com john@subaruferrari@.com   We are looking at modifying this pattern (and not using another pattern as this is in use in production and we do not want excessive changes) so as to accommodate the above use cases.   EDIT: Apologies everybody. Added the regex now.Although the existing answers on SO address pretty much the same situation (validating email addresses), however, I am looking just a quick modification the regex I am using.
291
Is there a regular expression to validate an email address in JavaScript?
66745
I'm using the Message module on Drupal 7.  For Replacement tokens, the help text says:     A comma-separated list of replacement tokens, e.g. %title or !url, of   which the message text makes use of. Each replacement token has to   start with one of the special characters "@", "%" or "!". This   character controls the sanitization method used, analogously to the   t() function.   What's the difference between %, !, and @?  Are there standards about when I should use each symbol?
18468
I'm developing an algorithm to parse a number out of a series of short-ish strings. These strings are somewhat regular, but there's a few different general forms and several exceptions. I'm trying to build a set of regexes that will handle the various forms and exceptions; I'll apply them one after another to see if I get a match.   One of these forms goes something like this:  X (Y) Z   Where:   X is a number I want to capture.  Z is static, pre-defined text. it's basically how I determine whether this particular form is applicable or not. Y is a a string of unknown length and content, surrounded by parenthesis.    Also: Y is optional; it doesn't always appear in a string with Z and X. So, I want to be able to extract the numbers from all of these strings:   10 Z 20 (foo) Z 30 (bar) Z   Right now, I have a regex that will capture the first one:  ([0-9]+) +Z   My problem is that I don't know how to construct a regex that will match a series of characters if and only if they're enclosed in parenthesis. Can this be done in a single regex?
74243
What symbols/characters are not allowed in tags?
37476
What is the easiest way to match non-ASCII characters in a regex? I would like to match all words individually in an input string, but the language may not be English, so I will need to match things like ü, ö, ß, and ñ. Also, this is in Javascript/jQuery, so any solution will need to apply to that.
39060
Whenever I try to insert " or ' I have to validate it by space, otherwise strange things happen as with ' followed by an a becomes áinstead of just 'a, similar behaviour with double quotes. I find this annoying and want to disable it. How do I do that?
17027
I'm trying to write a regular expression that validates a date.  The regex needs to match the following   M/D/YYYY MM/DD/YYYY Single digit months can start with a leading zero (eg: 03/12/2008) Single digit days can start with a leading zero (eg: 3/02/2008) CANNOT include February 30 or February 31 (eg: 2/31/2008)   So far I have   ^(([1-9]|1[012])[-/.]([1-9]|[12][0-9]|3[01])[-/.](19|20)\d\d)|((1[012]|0[1-9])(3[01]|2\d|1\d|0[1-9])(19|20)\d\d)|((1[012]|0[1-9])[-/.](3[01]|2\d|1\d|0[1-9])[-/.](19|20)\d\d)$   This matches properly EXCEPT it still includes 2/30/2008 &amp; 2/31/2008.  Does anyone have a better suggestion?  Edit: I found  on RegExLib  ^((((0[13578])|([13578])|(1[02]))[\/](([1-9])|([0-2][0-9])|(3[01])))|(((0[469])|([469])|(11))[\/](([1-9])|([0-2][0-9])|(30)))|((2|02)[\/](([1-9])|([0-2][0-9]))))[\/]\d{4}$|^\d{4}$   It matches all valid months that follow the MM/DD/YYYY format.  Thanks everyone for the help.
11336
How do you create a simple, custom rule using the jQuery Validate plugin (using ) that doesn't use a regex?  For example, what function would create a rule that validates only if at least one of a group of checkboxes is checked?
123543
I wonder if there is an easy way to check if two strings match by excluding certain characters in the strings. See example below.  I can easily write such a method by writing a regular expression to find the "wild card" characters, and replace them with a common character. Then compare the two strings str1 and str2. I am not looking for such implementations, but like to know whether there are any .Net framework classes that can take care of this. Seems like a common need, but I couldn't find any such method.  For example:  string str1 = "ABC-EFG";     string str2 = "ABC*EFG";   The two strings must be declared equal.  Thanks!
32515
I'm after a regex that will validate a full complex UK postcode only within an input string. All of the uncommon postcode forms must be covered as well as the usual. For instance:  Matches   CW3 9SS SE5 0EG SE50EG se5 0eg WC2H 7LT   No Match   aWC2H 7LT WC2H 7LTa WC2H   How do I solve this problem?
18267
The list of valid XML characters is well known, as defined by the spec it's:  #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]   My question is whether or not it's possible to make a PCRE regular expression for this (or its inverse) without actually hard-coding the codepoints, by using Unicode general categories. An inverse might be something like [\p{Cc}\p{Cs}\p{Cn}], except that improperly covers linefeeds and tabs and misses some other invalid characters.
65647
Pattern pattern = Pattern.compile("^[a-z]+$"); String string = "abc-def"; assertTrue( pattern.matcher(string).matches() ); // obviously fails   Is it possible to have the character class match a "-" ?
111512
I am using this method to try find a match, in an example:  Regex.Match("A2-TS-OIL", "TS-OIL", RegexOptions.IgnoreCase).Success;   I got a true result. I am confused. I think this should return false since there is no special characters in the pattern. If I use ".+TS-OIL", true should be returned (. for any and + for more than 1). How should I do to get what I need?
57802
I have a regex created from a list in a database to match names for types of buildings in a game. The problem is typos, sometimes those writing instructions for their team in the game will misspell a building name and obviously the regex will then not pick it up (i.e. spelling "University" and "Unversity").  Are there any suggestions on making a regex match misspellings of 1 or 2 letters?  The regex is dynamically generated and run on a local machine that's able to handle a lot more load so I have as a last resort to algorithmically create versions of each word with a letter missing and then another with letters added in.  I'm using PHP but I'd hope that any solution to this issue would not be PHP specific.
82194
I got a question when reading this text:     The name of the decorator should be prepended with an @ symbol.   Should we write "a @ symbol" or "an @ symbol"? As "@" is in fact "at", I would think "an" should be used to avoid the coexistence of two vowels one after the other.  More generally, what is the general rule to know if we have to write "a" or "an" before other symbols like "€", etc.? Is it based on how the symbol is read?
5821
I need a Perl regular expression to match a string. I'm assuming only double-quoted strings, that a \" is a literal quote character and NOT the end of the string, and that a \ is a literal backslash character and should not escape a quote character. If it's not clear, some examples:  "\""    # string is 1 character long, contains dobule quote "\\"    # string is 1 character long, contains backslash "\\\""  # string is 2 characters long, contains backslash and double quote "\\\\"  # string is 2 characters long, contains two backslashes   I need a regular expression that can recognize all 4 of these possibilities, and all other simple variations on those possibilities, as valid strings. What I have now is:  /".*[^\\]"/   But that's not right - it won't match any of those except the first one. Can anyone give me a push in the right direction on how to handle this?
20352
Is it possible to detect a valid regular expression with another regular expression?  If so please give example code below.