\s and \n

Get help using and writing Nisus Writer Pro macros.
Post Reply
User avatar
Matze
Posts: 170
Joined: 2004-12-14 07:54:49
Location: Düsseldorf Germany
Contact:

\s and \n

Post 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
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: \s and \n

Post 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.
User avatar
Matze
Posts: 170
Joined: 2004-12-14 07:54:49
Location: Düsseldorf Germany
Contact:

Re: \s and \n

Post by Matze »

Okay, I understand, is there an expression like \s in old NW only for spaces?
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: \s and \n

Post by martin »

There is no special symbolic escape for just a space, but you could use the character code escape, eg: "\x20" or "\u0020".
macduffee
Posts: 15
Joined: 2009-04-28 09:09:13
Location: Minneapolis, MN

Re: \s and \n

Post 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.
Post Reply