Reference - What does this regex mean?

Multi tool use
Reference - What does this regex mean?
This is a collection of common Q&A. This is also a Community Wiki, so everyone is invited to participate in maintaining it.
regex is suffering from give me ze code
type of questions and poor answers with no explanation. This reference is meant to provide links to quality Q&A.
give me ze code
This reference is meant for the following languages: php, perl, javascript, python, ruby, java, .net.
This might be too broad, but these languages share the same syntax. For specific features there's the tag of the language behind it, example:
This question's answers are a collaborative effort: if you see something that can be improved, just edit the answer to improve it! No additional answers can be added here
1 Answer
1
Online tutorials
Quantifiers
*
*?
*+
+
+?
++
?
{n,m}
{n,}
{n}
{n}
{n}?
Character Classes
[...]
[^...]
[^]
[w-[d]]
[a-z-[qz]]
[w&&[^d]]
[[:alpha:]]
[^D2]
[^[^0-9]2]
[^2[^0-9]]
d
D
w
W
s
S
p{L}, P{L}
Escape Sequences
h
t
r
n
R
H
V
N
v
e
Anchors
^
b
B
$
A
Z
z
Z
G
(Also see "Flavor-Specific Information → Java → The functions in Matcher
")
Matcher
Groups
(...)
(?:)
1
$1
g<1>123
1
(?i:regex)
(?P<group_name>regexp)
(?>)
(?|)
regular-expressions.info
(?<groupname>regex)
(?P<groupname>regex)
(?<groupname>regex)
(?<groupname>regex)
(?P<groupname>regex)
(?<groupname>regex)
Lookarounds
(?=...)
(?!...)
(?<=...)
(?<!...)
{0,n}
K
K
Modifiers
g
i
u
x
c
e
o
m
m
s
s
S
U
Other:
|
.
[.]
(*PRUNE)
(*SKIP)
(*FAIL)
(*F)
(*BSR_ANYCRLF)
(?R)
(?0)
(?1)
(?-1)
(?&groupname)
Common Tasks
{...}
Advanced Regex-Fu
(?!a)a
this
Flavor-Specific Information
(Except for those marked with *
, this section contains non-Stack Overflow links.)
*
java.util.regex.Matcher
matches()
find()
lookingAt()
java.lang.String
matches(s)
replaceAll(s,s)
replaceFirst(s,s)
split(s)
split(s,i)
java.util.regex
preg_match
search
match
regexp
General information
(Links marked with *
are non-Stack Overflow links.)
*
Examples of regex that can cause regex engine to fail
Tools: Testers and Explainers
(This section contains non-Stack Overflow links.)
Online (* includes replacement tester, + includes split tester):
freeformatter.com
regex.larsolavtorvik.com
Offline:
I don't understand this treatise. While it is (and has) a functional value and good links, nobody that is a beginner will ever understand anything past the first line. Therefore it is useless as an instructional tool. It's title
Reference - What does this regex mean?
does not tell you what any particular regex means. It is a mish-mash of links.. an overwhelming blend if you will, of the universe of regex constructs from different engines. To make things worse, some people mark regex questions as a direct duplicate of this question. It's sad ..– sln
Apr 15 '17 at 19:35
Reference - What does this regex mean?
@sln, I think the correct usage would be to look up the answer to a newly asked regex question in this reference, find the linked Q&A that really does answer the new question and is a dupe, mark the new question as a dupe of that post, and add a comment linking to this page.
– Wildcard
Jun 21 '17 at 22:26
@Wildcard - This page is/should definitely be for comment linking after some introductory, general info. But, I've seen it used inappropriately as a direct duplicate too many times.
– sln
Jun 21 '17 at 23:59
@sln A rare example of when you should shoot the messenger.
– bye
Sep 26 '17 at 15:07
Tried to edit this, but can't do it because "it appears your post contains code that is not formatted correctly". I wanted to change the sentence "When to not use regular expressions:" to ""When not to use regular expressions:". The reason is that on the "Common tasks" section it appears with this word order, and because there is no link, I tried to use the browser search and could not find the corresponding section.
– zelite
Jan 24 at 11:53
I created a meta discussion, everyone is invited >>>
– HamZa
Apr 8 '14 at 18:26