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
/
\(*[A-Z][a-z]+\)*
/
gm
Input 1
1
New
ItIsBeautiful // It Is Beautiful itIsBeautiful // It Is Beautiful Active-UserHere // Active-User Here Active-USERHere // Active-USER Here active-USERHere // Active-USER Here anActive-USERHere // Active-USER Here AnActive-USERHere // Active-USER Here iAmFromTheUSAAndA // I Am From The USA And A IAmFromTheUSAAndA // I Am From The USA And A IAmFromTheUSA // I Am From The USA amazing(Stuff-abc)AndMore // Amazing (Stuff-ABC) And More Amazing(Stuff-abc)AndMore // Amazing (Stuff-ABC) And More Amazing(Stuff-ABC)AndMore // Amazing (Stuff-ABC) And More Amazing(Stuff-ABC)andMore // Amazing (Stuff-ABC) And More Amazing(Stuff-Abc)andMore // Amazing (Stuff-Abc) and More Amazing(Stuff-abc) // Amazing (Stuff-abc) Amazing(Stuff) // Amazing (Stuff) Amazing(Stuff-Abc)(Stuff) // Amazing (Stuff-Abc) (Stuff) Test1345Test3and(USA)And-4-5-testTest-2-3Test Test1345Test3andUSAAnd-4-5-testTest-2-3Test Test13-45Test3AndUSAAnd-4-5-testTest-2-3Test # 1st replacement step (version 1) # # ... either strict ... # #\(*[A-Z][a-z]+\)* # # ... or more forgiving/loose ... # \(*(?:[A-Z]|(?<=\d))[a-z]+\)* # # '...'.replace(/\(*[A-Z][a-z]+\)*/g, ' $& ') # '...'.replace(/\(*(?:[A-Z]|(?<=\d))[a-z]+\)*/g, ' $& ') It Is Beautiful // It Is Beautiful it Is Beautiful // It Is Beautiful Active - User Here // Active-User Here Active -USER Here // Active-USER Here active-USER Here // Active-USER Here an Active -USER Here // Active-USER Here An Active -USER Here // Active-USER Here i Am From The USA And A // I Am From The USA And A I Am From The USA And A // I Am From The USA And A I Am From The USA // I Am From The USA amazing (Stuff -abc) And More // Amazing (Stuff-ABC) And More Amazing (Stuff -abc) And More // Amazing (Stuff-ABC) And More Amazing (Stuff -ABC) And More // Amazing (Stuff-ABC) And More # does fail, not covered intentionally cause it already initially violates the rules Amazing (Stuff -ABC)and More // Amazing (Stuff-ABC) And More Amazing (Stuff - Abc) andMore // Amazing (Stuff-Abc) and More Amazing (Stuff -abc) // Amazing (Stuff-abc) Amazing (Stuff) // Amazing (Stuff) Amazing (Stuff - Abc) (Stuff) // Amazing (Stuff-Abc) (Stuff) # does fail for \(*[A-Z][a-z]+\)* # not covered intentionally cause it already initially violates the rules Test 1345 Test 3and(USA) And -4-5-test Test -2-3 Test Test 1345 Test 3andUSA And -4-5-test Test -2-3 Test # does not fail with the usage of \(*(?:[A-Z]|(?<=\d))[a-z]+\)* Test 1345 Test 3 and (USA) And -4-5-test Test -2-3 Test Test 1345 Test 3 and USA And -4-5-test Test -2-3 Test Test 13-45 Test 3 And USA And -4-5-test Test -2-3 Test # 2nd replacement step (version 2) # \s*-\s* # # '...'.replace(/\s*-\s*/g, '-') # 3rd replacement step # # '...'.replace(/\s+/g, ' ') # last # '...'.trim()