Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
/
(?<!\\) # Check it was not escaped with a \ (?<bold_all> (?<bold_type>\*{2}|\_{2}) # Emphasis type: * or _ (?= # followed by non-space (?: (?:[_*`\$\\]) # avoid punctuation except those | (?![[:punct:]]) ) \S) (?<bold_text>.+?[*_]*) # enclosed text (?<=\S) # making sure preceding stuff was a non-space \g{bold_type} # Balanced closing tag )
/
gx
Unit Tests