[tpm] New Regex question - partially solved
Rob Janes
janes.rob at gmail.com
Sat Oct 27 16:42:17 PDT 2012
Slurp the file and run the second regex.
undef $/;
$exp = <in>;
$exp =~ s/(\s)\1+/\1/g;
Not sure $/.
On Oct 27, 2012 6:48 PM, "Chris Jones" <cj at enersave.ca> wrote:
>
>
> 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
>
> ______________________________**_________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/**listinfo/toronto-pm<http://mail.pm.org/mailman/listinfo/toronto-pm>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20121027/97f2db79/attachment.html>
More information about the toronto-pm
mailing list