Replace multiple spaces

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 TextThe   "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 ResultThe "brown     fox" jumped over... 
posted @ 2007-06-08 17:18  过河卒A  阅读(296)  评论(1编辑  收藏  举报