It is currently April 26th, 2024, 8:46 am

How to delete all white spaces ?

Get help with creating, editing & fixing problems with skins
trinhanhngoc
Posts: 23
Joined: May 23rd, 2010, 3:48 pm

How to delete all white spaces ?

Post by trinhanhngoc »

I use WebParser to get one data on internet. Example:
...
RegExp="(?siU)...(.*)..."
...
(.*) -> " #very much white spaces# Stairway to Heaven"
How to delete all white spaces before the value ?
Become :
(.*) -> "Stairway to Heaven".
User avatar
Alex2539
Rainmeter Sage
Posts: 642
Joined: July 19th, 2009, 5:59 am
Location: Montreal, QC, Canada

Re: How to delete all white spaces ?

Post by Alex2539 »

Try using \s*(\S.*) instead of (.*). The "\s" is shorthand for any whitespace, whereas "\S" is shorthand for anything that's NOT whitespace. Basically, this says to go through whitespace characters, until it hits a non-whitespace character, at which point it saves the rest. If you had a file like this:

Code: Select all

<tag1>                       SOME STUFF</tag1>
And then used this RegExp:

Code: Select all

RegExp="(?siU)<tag1>\s*(\S.*)</tag1>"
The result would be "SOME STUFF".
ImageImageImageImage
trinhanhngoc
Posts: 23
Joined: May 23rd, 2010, 3:48 pm

Re: How to delete all white spaces ?

Post by trinhanhngoc »

Thanks you. More...
\s*(\S.*) Before String
(\S.*)\s* After String
\s*(\S.*)\s* Before & After String.