in reply to Re: Why split function treats single quotes literals as regex, instead of a special case?
in thread Why split function treats single quotes literals as regex, instead of a special case?
The single space character is a special case for split ...I.e., per split:
As another special case, split emulates the default behavior of the command line tool awk when the PATTERN is either omitted or a string composed of a single space character (such as ' ' or "\x20", but not e.g. / /). In this case, any leading whitespace in EXPR is removed before splitting occurs, and the PATTERN is instead treated as if it were /\s+/; in particular, this means that any contiguous whitespace (not just a single space character) is used as a separator.You also write:
Regular expressions are also treated a bit differently than regular expressions in qr//, m// and s///.I don't understand this statement. Can you elaborate?
Give a man a fish: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Why split function treats single quotes literals as regex, instead of a special case?
by jwkrahn (Abbot) on Aug 14, 2020 at 09:16 UTC | |
by AnomalousMonk (Archbishop) on Aug 14, 2020 at 18:17 UTC | |
by jcb (Parson) on Aug 14, 2020 at 23:07 UTC |