in reply to Re: \s matches newline in regex?
in thread \s matches newline in regex?

So if \s matches more than a space, how do I match just a space? While I agree your suggestion works for my simple example, it won't work for my actual workload.

Replies are listed 'Best First'.
Re^3: \s matches newline in regex?
by Corion (Patriarch) on Jul 22, 2015 at 17:04 UTC

    You can use [ ], or \x{20} or \U{0020} I guess.

Re^3: \s matches newline in regex?
by GrandFather (Saint) on Jul 22, 2015 at 20:58 UTC

    If you want just a space use just a space! If you want to match everything except some specific white space characters use a negated character class with \S and the other white space characters you want to keep:

    s/Hi[^\S\n\r\f]+//g

    for example.

    Premature optimization is the root of all job security