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
/
(?:\G(?!\A)|\()[^()]*?\K(?:(?<=\()\s+|\s+(?=\))|\s{2,})(?=[^()]*\))
/
gm
Input 1
1
New
( R:2379; L: 28 ) //replace to (R:2379; L:28) #a single space is ok, except before or after a parentheses. Multiple spaces are reduced to blank. (R:2432;L:28) // ok, no replacements needed (R:2432; L: 28) // ok, no replacements needed. The single spaces are not before or after the parentheses ( R : 2475; L: 28 ) // replace to (R:2475; L:28) #the single space before the L is fine. other multiple spaces are blanked ( R : 2480 ; L: 28 ) // replace to (R:2480; L: 28) #the single space before the 28 is fine ( R:2379; L: 28 ) //replace to (R:2379;L:28) R:2379;L:28 (R:2432;L:28) // ok, no replacements needed R:2432; L:28 ( R : 2475; L: 28 ) // replace to (R:2475;L:28) R:2475; L:28 ( R : 2480 ; L:28 ) // replace to (R:2480;L:28) R:2480; L:28
Substitution
( R:2379; L: 28 ) //replace to (R:2379; L:28) #a single space is ok, except before or after a parentheses. Multiple spaces are reduced to blank. (R:2432;L:28) // ok, no replacements needed (R:2432; L: 28) // ok, no replacements needed. The single spaces are not before or after the parentheses ( R : 2475; L: 28 ) // replace to (R:2475; L:28) #the single space before the L is fine. other multiple spaces are blanked ( R : 2480 ; L: 28 ) // replace to (R:2480; L: 28) #the single space before the 28 is fine ( R:2379; L: 28 ) //replace to (R:2379;L:28) R:2379;L:28 (R:2432;L:28) // ok, no replacements needed R:2432; L:28 ( R : 2475; L: 28 ) // replace to (R:2475;L:28) R:2475; L:28 ( R : 2480 ; L:28 ) // replace to (R:2480;L:28) R:2480; L:28