Regular expression to match a word or its prefix

Square brackets are meant for character class, and you’re actually trying to match any one of: s, |, s (again), e, a, s (again), o and n. Use parentheses instead for grouping: or non-capturing group: Note: Non-capture groups tell the engine that it doesn’t need to store the match, while the other one (capturing group does). For small stuff, either works, for ‘heavy duty’ stuff, you … Read more

Searching for UUIDs in text with regex

I agree that by definition your regex does not miss any UUID. However it may be useful to note that if you are searching especially for Microsoft’s Globally Unique Identifiers (GUIDs), there are five equivalent string representations for a GUID:

Remove properties from objects (JavaScript)

To remove a property from an object (mutating the object), you can do it like this: Demo For anyone interested in reading more about it, Stack Overflow user kangax has written an incredibly in-depth blog post about the delete statement on their blog, Understanding delete. It is highly recommended. If you’d like a new object with all the keys of the original … Read more

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

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