Re: Find duplicate numbers and replace
Re: Find duplicate numbers and replace
- Subject: Re: Find duplicate numbers and replace
- From: Skeeve <email@hidden>
- Date: Wed, 14 May 2008 22:45:44 +0200
Mark J. Reed schrieb:
If you just add /g to your s//, it shouldn't matter what the line
endings are... The example file had all the matching numbers at the
beginning of a line, but that doesn't affect the logic of the solution
if you do a global search.
Not quite. If we want to make sure it's a line start we have to anchor
using ^. But then we'll have to add "m" to the "g" and still won't get
every platform. If you let this run:
perl -e '
my %eols= (
CR_OLD_MAC => "\015",
LF_UNIX => "\012",
CRLF_DOS => "\015\012",
LFCR_OBSCURE => "\012\015",
);
while (my($n,$eol)=each %eols) {
print $n,"\n";
$_= join($eol,1..6);
print join("\n",/^(\d+)/gm),"\n\n";
}
'
You'll quickly see what I mean:
LFCR_OBSCURE
1
CR_OLD_MAC
1
LF_UNIX
1
2
3
4
5
6
CRLF_DOS
1
2
3
4
5
6
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden