Date: Sun, 26 Jun 2016 16:44:44 +0200 From: =?utf-8?Q?Dani=C3=ABl_de_Kok?= <me@danieldk.eu> To: Polytropon <freebsd@edvax.de> Cc: freebsd-questions@freebsd.org Subject: Re: grep and anchoring Message-ID: <362EE01F-4B49-4ADB-A3A6-43F852FFF87F@danieldk.eu> In-Reply-To: <20160626163411.d05f863e.freebsd@edvax.de> References: <20232C89-B821-41EC-9188-C2A19C679BD8@danieldk.eu> <20160626163411.d05f863e.freebsd@edvax.de>
next in thread | previous in thread | raw e-mail | index | archive | help
On 26 Jun 2016, at 16:34, Polytropon <freebsd@edvax.de> wrote: > Or is this just an "enrichment" your MUA added? :-) Yes, Mac=E2=80=99s Mail.app likes to replace these. I didn=E2=80=99t use = an ellipsis in the actual expression ;), just four dots. > % echo "1234 1234 1234" | egrep -o '^....' > 1234 > 123 > 4 12 [...] > First 4-character pattern is "1234", next is " 123", > and last is "4 12" (each 4 characters wide, as the > space character " " is also "any character" that matches > the . pattern). In the second example, the groups match > 4 characters each ("1234" x 3). Note the anchoring (^), the pattern should only match any four = characters at the beginning of the line, so the expected output is = =E2=80=981234=E2=80=99 and nothing more. =E2=80=98 123' and '4 12' are = not at the beginning of the line and should consequently not be printed = to stdout. For comparison, the output of a recent GNU grep: =E2=80=94 % echo "1234 1234 1234" | grep -o '^....' 1234 =E2=80=94 With kind regards, Dani=C3=ABl de Kok=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?362EE01F-4B49-4ADB-A3A6-43F852FFF87F>