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
***test
test***
→ capture group 0 starts with
empty string
___test
test___
→ capture group 0 starts with
empty string
*test
**test***
→ capture group 0 starts with
empty string
**test
*test***
→ capture group 0 starts with
empty string
***test*
test**
→ capture group 0 starts with
empty string
***test**
test*
→ capture group 0 starts with
empty string
***test*
test**
→ capture group 0 starts with
empty string
**test
*test***
→ capture group 0 starts with
empty string
*test
**test***
→ capture group 0 starts with
empty string
_test
__test___
→ capture group 0 starts with
empty string
__test
_test___
→ capture group 0 starts with
empty string
___test_
test__
→ capture group 0 starts with
empty string
___test__
test_
→ capture group 0 starts with
empty string
___test_
test__
→ capture group 0 starts with
empty string
__test
_test___
→ capture group 0 starts with
empty string
_test
__test___
→ capture group 0 starts with
empty string
*test
__test__*
→ capture group 0 starts with
empty string
**test
_test_**
→ capture group 0 starts with
empty string
**_test_
test**
→ capture group 0 starts with
empty string
*__test__
test*
→ capture group 0 starts with
empty string
**_test_
test**
→ capture group 0 starts with
empty string
**test
_test_**
→ capture group 0 starts with
empty string
*test
__test__*
→ capture group 0 starts with
empty string
_test
**test**_
→ capture group 0 starts with
empty string
__test
*test*__
→ capture group 0 starts with
empty string
__*test*
test__
→ capture group 0 starts with
empty string
_**test**
test_
→ capture group 0 starts with
empty string
__*test*
test__
→ capture group 0 starts with
empty string
__test
*test*__
→ capture group 0 starts with
empty string
_test
**test**_
→ capture group 0 starts with
empty string
*test
**test*
test**
→ capture group 0 starts with
empty string
_test
__test_
test__
→ capture group 0 starts with
empty string
**test
*test**
test*
→ capture group 0 starts with
empty string
__test
_test__
test_
→ capture group 0 starts with
empty string
**test
**test**
test**
→ capture group 0 starts with
empty string
__test
__test__
test__
→ capture group 0 starts with
empty string
_**some
text_**
→ capture group 0 starts with
empty string
*__some
text*__
→ capture group 0 starts with
empty string
**_some
text**_
→ capture group 0 starts with
empty string
*test
*test*
test*
→ regex does not match
test*
test
*test
→ regex does not match
test**
test
**test
→ regex does not match
test_
test
_test
→ regex does not match
test__
test
__test
→ regex does not match
*a*b
→ regex does not match
__a__b
→ capture group 0 starts with
empty string
a__b__
→ capture group 0 starts with
empty string
a__b__c
→ capture group 0 starts with
empty string
E**.
**Test**
TestTestTest
→ capture group 0 starts with
empty string
E**.
**Test**
Test
Test
Test
→ capture group 0 starts with
empty string