How to validate an email address in JavaScript

Using regular expressions is probably the best way. You can see a bunch of tests here (taken from chromium) Here’s the example of regular expresion that accepts unicode: But keep in mind that one should not rely only upon JavaScript validation. JavaScript can easily be disabled. This should be validated on the server side as well. Here’s an example of … Read more

Regex how to match an optional character

Use to make the letter optional. {1} is redundant. (Of course you could also write [A-Z]{0,1} which would mean the same, but that’s what the ? is there for.) You could improve your regex to And, since in most regex dialects, \d is the same as [0-9]: But: do you really need 11 separate capturing groups? And if so, why don’t you capture the … Read more

How to replace ” \ ” with ” \\ ” in java

Don’t use String.replaceAll in this case – that’s specified in terms of regular expressions, which means you’d need even more escaping. This should be fine: Note that the backslashes are doubled due to being in Java string literals – so the actual strings involved here are “single backslash” and “double backslash” – not double and quadruple. replace works on simple … Read more

Grep and Python

I need a way of searching a file using grep via a regular expression from the Unix command line. For example when I type in the command line: I need the regular expression ‘RE’ to be searched in the file and print out the matching lines. Here’s the code I have: But when I enter a word … Read more

How to use Regular Expressions (Regex) in Microsoft Excel both in-cell and loops

1066 Regular expressions are used for Pattern Matching. To use in Excel follow these steps: Step 1: Add VBA reference to “Microsoft VBScript Regular Expressions 5.5” Select “Developer” tab (I don’t have this tab what do I do?) Select “Visual Basic” icon from ‘Code’ ribbon section In “Microsoft Visual Basic for Applications” window select “Tools” from … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)