From owner-freebsd-questions@FreeBSD.ORG Fri Dec 19 01:35:43 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C3C602FE for ; Fri, 19 Dec 2014 01:35:43 +0000 (UTC) Received: from dnvrco-oedge-vip.email.rr.com (dnvrco-outbound-snat.email.rr.com [107.14.73.228]) by mx1.freebsd.org (Postfix) with ESMTP id 8EE9E2ECC for ; Fri, 19 Dec 2014 01:35:42 +0000 (UTC) Received: from [204.210.114.114] ([204.210.114.114:40387] helo=localhost.hawaii.res.rr.com) by dnvrco-oedge02 (envelope-from ) (ecelerity 3.5.0.35861 r(Momo-dev:tip)) with ESMTP id 61/3F-12444-7E083945; Fri, 19 Dec 2014 01:35:36 +0000 Received: by localhost.hawaii.res.rr.com (Postfix, from userid 1000) id 17CB05C9A; Thu, 18 Dec 2014 15:39:56 -1000 (HST) Date: Thu, 18 Dec 2014 15:39:55 -1000 From: parv@pair.com To: Robert Bonomi Subject: Re: Perl rename utility assistance Message-ID: <20141219013955.GA1591@holstein.holy.cow> Mail-Followup-To: Robert Bonomi , freebsd-questions@freebsd.org References: <54907B51.1060807@gmail.com> <201412171838.sBHIcOht031153@host203.r-bonomi.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201412171838.sBHIcOht031153@host203.r-bonomi.com> X-RR-Connecting-IP: 107.14.64.130:25 X-Authority-Analysis: v=2.1 cv=Zu1jKrLG c=1 sm=1 tr=0 a=lLOF/jpPrR0dcgWXP1EvZg==:117 a=lLOF/jpPrR0dcgWXP1EvZg==:17 a=ayC55rCoAAAA:8 a=kj9zAlcOel0A:10 a=Ymsr-CWnAAAA:8 a=A92cGCtB03wA:10 a=lM4-zUH5AAAA:8 a=ZmHAvgfS8omts-_tP30A:9 a=CjuIK1q_8ugA:10 X-Cloudmark-Score: 0 Cc: freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Dec 2014 01:35:43 -0000 in message <201412171838.sBHIcOht031153@host203.r-bonomi.com>, wrote Robert Bonomi thusly... > ... > Your regex "^[:digit:]_" says: > "^" start at the beginning of the name > "[:digit:]" match one character from the following list ':digt' > "_" match an underscore > > For some strange reason, this does not cause a match where there > are leading digits, . > to match a single character in the range '0'-'9', the syntax is > '[[digit:]]' ... The proper character class to match a digit is "[[:digit:]]", similar to "[0-9]". Pattern "[:digit:]" is to match numbers in the locale set, to match any number not just those in range "0-9" (ASCII). When run with "warnings" pragma when trying to match /^[:digit:]/, the problem is shown ... perl -Mwarnings -e 'my $x = q[234y] ; print $x =~ m/^([:digit:])/ ' POSIX syntax [: :] belongs inside character classes in regex; \ marked by <-- HERE in m/^([:digit:] <-- HERE )/ at -e line 1. ... (mind that nothing is printed as nothing was matched, but not due to the warning message itself). Run the above with "diagnostics" pragma for more information .... perl -Mdiagnostics -Mwarnings -e ' ... ' On a side note ... perl -Mwarnings -e 'my $x = q[xyz] ; $x =~ s/x(y)/y\1/ ; print $x' \1 better written as $1 at -e line 1. yyz --