From owner-freebsd-questions@freebsd.org Sun Jun 26 14:44:47 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 66BF9B81C2A for ; Sun, 26 Jun 2016 14:44:47 +0000 (UTC) (envelope-from me@danieldk.eu) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3CDF12BB8 for ; Sun, 26 Jun 2016 14:44:46 +0000 (UTC) (envelope-from me@danieldk.eu) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id B7EA020417; Sun, 26 Jun 2016 10:44:45 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Sun, 26 Jun 2016 10:44:45 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=danieldk.eu; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=PLFKrlAUa9ijoZKC+EQW2n2U4Ok=; b=IYCOqI uqGFFwqd9vzM/ZhkL/4q+4gIm4W6WCC8toNb3e+/CR8icxClM0A2xl9AycqBwEi3 eI9P2BeAGu7bjutLvppJVKOSkjnGwHnMfg4AvYCQrtRWr6r7yK7ZD4ZpVjeX77xY zHc1oEKkfqwELp2Z5Zv34LCgg6qqwXZkt5VGA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=PLFKrlAUa9ijoZK C+EQW2n2U4Ok=; b=VX/Qp1bkjWi8I+1V0o9eSo2Pj5PgU3qK4hdvVJrcliMNIGu bHCCqmqWGZlh+gjavicHO3Eyq1GmM/DDgm9x+yDDjsd+yeo03bQ7M/zUh9hiCVXW NHRP3fB5raRQS6ulbKLvO9bG/GLA18WTBMUeLJ2ztvXdmfW5p9kectdvr5Vg= X-Sasl-enc: lu41RXQ1cMrDFPKrusYjeFEZmPjTT9Ov82X93h40sVDF 1466952285 Received: from daniels-macbook.fritz.box (hsi-kbw-046-005-018-048.hsi8.kabel-badenwuerttemberg.de [46.5.18.48]) by mail.messagingengine.com (Postfix) with ESMTPA id 29064CC01B; Sun, 26 Jun 2016 10:44:45 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: grep and anchoring From: =?utf-8?Q?Dani=C3=ABl_de_Kok?= In-Reply-To: <20160626163411.d05f863e.freebsd@edvax.de> Date: Sun, 26 Jun 2016 16:44:44 +0200 Cc: freebsd-questions@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <362EE01F-4B49-4ADB-A3A6-43F852FFF87F@danieldk.eu> References: <20232C89-B821-41EC-9188-C2A19C679BD8@danieldk.eu> <20160626163411.d05f863e.freebsd@edvax.de> To: Polytropon X-Mailer: Apple Mail (2.3124) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Jun 2016 14:44:47 -0000 On 26 Jun 2016, at 16:34, Polytropon 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=