Page 1 of 1

\s and \n

Posted: 2011-06-28 02:03:32
by Matze
Hi there,

I wanted to replace all double-spaces or more by one space and wrote Find '\s\s+' and Replace '\s' in the FR Window and hit replace all.
This 1. made NWP to replace doublespaces with the letter s.
And 2. it also replaced spaces followed by a return.

So does this mean I have to write something else in the replace part, to make NWP replace something with a space??
And does this mean, that \s is not only a space but a return as well?

Best Matze

Re: \s and \n

Posted: 2011-06-28 09:16:02
by martin
Matze wrote:So does this mean I have to write something else in the replace part, to make NWP replace something with a space??
Yes, you can just type in a normal space. No special code/escape is required.
And does this mean, that \s is not only a space but a return as well?
That's correct. In regular expressions "\s" stands for any whitespace, and includes spaces, newlines, tabs, half-width spaces, etc.

Re: \s and \n

Posted: 2011-06-28 23:40:18
by Matze
Okay, I understand, is there an expression like \s in old NW only for spaces?

Re: \s and \n

Posted: 2011-06-28 23:44:04
by martin
There is no special symbolic escape for just a space, but you could use the character code escape, eg: "\x20" or "\u0020".

Re: \s and \n

Posted: 2011-07-01 12:23:45
by macduffee
This is good to know. I used the \s religiously in 6.5 myself. It only found spaces, not returns (\r) or tabs (\t). It's very hard to teach an old dog new tricks.