[导入]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... 


suiqirui 2007-06-08 17:18 发表评论

文章来源:http://www.cnblogs.com/suiqirui19872005/archive/2007/06/08/776840.html

posted on 2007-06-19 14:52  温温恭人  阅读(137)  评论(0编辑  收藏  举报

导航