Hi Tim,

 

Sorry example was not clear, Im looking to remove any multiple spaces throughout the sentence unless they are enclosed within speech marks.

 

Therefore in the following sentence I am looking to remove the extra spaces between "brown" and "fox" and "fox" and "jumped"

 

The brown     fox   jumped over....

 

however if enclosed in speech marks as as per the next example then I only want to remove extra line spaces between "fox" and "jumped"

 

The "brown     fox"    jumped over...

 

Hope this is clearer.

 

Thank you.

 

 

Sunny




Note in the replace there is a space such as "${Text} " ....
Input Text The   "brown     fox"    jumped over...
Regular Expression

(?(\x22)                     # If it starts with a quote, keep it as is
  (?<Text>\x22[^\x22]*\x22)  # Extract it to Named capture group
 |
  (?<Text>[^\s]*)            # Extract to NCG
)
(\s*)                        # Match spaces/tabs to eleminate them.

Replace Pattern

${Text


Replacement Result The "brown     fox" jumped over... 

相关文章: