[tpm] New Regex question - partially solved
Chris Jones
cj at enersave.ca
Sat Oct 27 15:48:33 PDT 2012
Progress:
An example of the text I am trying to regex:
Expression:
if(Local(TYPE) == 1) then
1.25
else
UNCHANGED
endif
I would like:
Expression after:
if(Local(TYPE) == 1) then
1.25
else
UNCHANGED
endif
$Expression =~ s/(\s)\1*/\1/g; #gives me:
if(Local(TYPE) == 1) then
1.25
else
UNCHANGED
endif
But I can't figure out how to match the double carriage return?
At 07:55 PM 23/10/2012, Stuart Watt wrote:
>On 2012-10-23, at 2:32 PM, Chris Jones <cj at enersave.ca> wrote:
>
> > My tests are working correctly, I don't try to delete directories.
> >
> > My follow on question is how do you tell File:Find to skip the
> directory the script is called from. I only want to delete files
> in the sub-directories.
> >
> > I can test each file to see if it's directory is '.' but would
> seem somewhat inefficient?
>
>String matching efficiency is probably a thousand times higher than
>file system accesses, so if I was you I really wouldn't worry about
>it. I tend to use no_chdir => 1 and $File::Find::name, but to skip
>everything in the base directory, probably checking to see if
>$File::Find::dir is the same as the base should be quick and effective.
>
>All the best
>Stuart
>_______________________________________________
>>
Christopher Jones, P.Eng.
Suite 1801, 1 Yonge Street
Toronto, ON M5E1W7
Tel. 416-203-7465
Fax. 416-946-1005
email cj at enersave.ca
More information about the toronto-pm
mailing list