Dave Loepr
Dave Loepr

Reputation: 956

Regex to remove white spaces in sublime text 2

I have this string in an xml file :

<wp:meta_value><![CDATA[1 600 €               ]]></wp:meta_value>

and I'd like it to be :

<wp:meta_value><![CDATA[1600 €]]></wp:meta_value>

I'm trying to do this within the find tool of sublime text 2, so far I have for find :

 <wp:meta_value>(.*?)</wp:meta_value>

and for replace :

 <wp:meta_value>$1</wp:meta_value>

Any help appreciated !

Upvotes: 0

Views: 3409

Answers (3)

Urvah Shabbir
Urvah Shabbir

Reputation: 985

Press Ctrl + H to open find and replace option.

Find What: \s+

Replace With: \s

\s looks for spaces. + looks for repetitions of \s. Replacing it with \s replaces consecutive spaces with a single one.

This works in Sublime v3.

Upvotes: 0

jingx
jingx

Reputation: 4014

Search for \s\+] and replace with ]

I'm not familiar with sublime. If the above doesn't work it's possible that you need to escape the ] in the search string as \].

Upvotes: 0

Andrew Cheong
Andrew Cheong

Reputation: 30283

You might want to look over a tutorial for regular expressions. You want to find

_+

where _ is a space, and replace it with

_

Upvotes: 1

Related Questions