[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gawk] third argument to split() always behaves like FS, and the doc
From: |
R |
Subject: |
[bug-gawk] third argument to split() always behaves like FS, and the docs are not clear about it |
Date: |
Mon, 26 Nov 2018 05:33:59 +0200 |
If the third argument to split() is made up of a single character, it
will NOT be treated as a regular expression:
$ gawk 'BEGIN{print split("foo.bar", a, "."); print a[1], a[2]}'
2
foo bar
But:
$ gawk 'BEGIN{print split("foo.bar", a, /./); print a[1], a[2]}'
8
This is (for me) completely expected, and it's the way it works in all
awk implementations I know of.
But neither the man nor the info page of gawk are clear about it --
they both talk about the 3rd argument as of a 'regular expression'.
The info page goes into some detail about the case where it's a single
space, but does not say anything about the case where it's a special
character like '.' or '('.
Here is the question and my awkward attempt to answer it that triggered this:
https://unix.stackexchange.com/a/483874/308316
- [bug-gawk] third argument to split() always behaves like FS, and the docs are not clear about it,
R <=