Skip to main content
5469 votes
78 answers
4.9m views

I'd like to check if the user input is an email address in JavaScript, before sending it to a server or attempting to send an email to it, to prevent the most basic mistyping. How could I achieve this?...
5468 votes
35 answers
5.5m views

I know it's possible to match a word and then reverse the matches using other tools (e.g. grep -v). However, is it possible to match lines that do not contain a specific word, e.g. hede, using a ...
4309 votes
78 answers
2.8m views

Over the years I have slowly developed a regular expression that validates most email addresses correctly, assuming they don't use an IP address as the server part. I use it in several PHP programs, ...
2498 votes
18 answers
1.3m views

How are non-capturing groups, i.e., (?:), used in regular expressions and what are they good for?
never_had_a_name's user avatar
2356 votes
36 answers
4.0m views

I need to match all of these opening tags: <p> <a href="foo"> But not self-closing tags: <br /> <hr class="foo" /> I came up with this and wanted to make ...
1976 votes
29 answers
1.4m views

I would like to create a String.replaceAll() method in JavaScript and think using a regex would be the most terse way to do it. However, I can't figure out how to pass a variable into a regex. I can ...
JC Grubbs's user avatar
  • 40.5k
1762 votes
24 answers
1.1m views

I want to match a portion of a string using a regular expression and then access that parenthesized substring: var myString = "something format_abc"; // I want "abc" var arr = /(?:^|\s)format_(.*?...
nickf's user avatar
  • 548k
1389 votes
3 answers
1.4m views

How do I match all lines not matching a particular pattern using grep? I tried this: grep '[^foo]'
jerrygarciuh's user avatar
  • 22.3k
1352 votes
4 answers
111k views

I made a comment yesterday on an answer where someone had used [0123456789] in a regex rather than [0-9] or \d. I said it was probably more efficient to use a range or digit specifier than a character ...
weston's user avatar
  • 55k
1216 votes
15 answers
1.6m views

I want to use JavaScript (I can also use jQuery) to do check whether a string matches the regex ^([a-z0-9]{5,})$, and get a true or false result. match() seems to check whether part of a string ...
Richard's user avatar
  • 33.1k
1172 votes
10 answers
273k views

Is it possible to detect a valid regular expression with another regular expression? If so please give example code below.
psytek's user avatar
  • 9,261
1092 votes
68 answers
772k views

How can I check if a given string is a valid URL address? My knowledge of regular expressions is basic and doesn't allow me to choose from the hundreds of regular expressions I've already seen on the ...
Vitor Silva's user avatar
  • 17.8k
1060 votes
46 answers
1.2m views

I'm trying to put together a comprehensive regex to validate phone numbers. Ideally it would handle international formats, but it must handle US formats, including the following: 1-234-567-8901 1-234-...
1041 votes
16 answers
1.3m views

Obviously, you can use the | (pipe?) to represent OR, but is there a way to represent AND as well? Specifically, I'd like to match paragraphs of text that contain ALL of a certain phrase, but in no ...
hugoware's user avatar
  • 36.4k
932 votes
45 answers
1.5m views

I want a regular expression to check that: contains at least eight characters, including at least one number and includes both lower and uppercase letters and include at least one special characters, ...
Swapnil Tatkondawar's user avatar

15 30 50 per page
1
2 3 4 5
17411