APM: Regular Expression Question

David Bluestein II dbii at interaction.net
Wed Aug 16 09:12:09 PDT 2006


The interval qualifier matches number of characters adjacent, so this 
would match strings (excluding double quotes):

""
"\t"
"\t\t"
"\t\t\t"

so it is looking for \t adjacent to each other.

David

On Aug 16, 2006, at 10:32 AM, Jay Flaherty wrote:

> try
> $piece =~ s/\t{0,3}/\"\t\"/g;
> This is an interval quantifier where {0,3} means you require a minimum
> of 0 matches up to a maximum of 3 matches
>
> This is untested of course.
>
> Jay
>
> On 8/16/06, Barron Snyder (CE CEN) <Barron.Snyder at wholefoods.com> 
> wrote:
>>
>>
>>
>>
>> $piece =~ s/\t/\"\t\"/g;
>>
>>
>>
>> With the above code I'm searching for all tab characters and 
>> replacing them
>> with a tab surrounded by double-quotes. Is there a way without 
>> putting this
>> in a coding loop, to replace say, only the first three instances it 
>> finds in
>> $piece? It seems like a nice way to do this would to be able to 
>> replace the
>> "g" with an integer indicating how many replacements to do but it 
>> doesn't
>> seem to work like that <grin>.
>>
>>
>>
>> I'm parsing some columnar data (7 columns) and I want to put 
>> double-quotes
>> around the first six columns. I've figured out a way to do it but 
>> it's kind
>> of clumsy. I thought you experts may be able to show a Perl newbie a 
>> more
>> elegant way to do it.
>>
>>
>>
>> Thanks,
>>
>>
>>
>> Barron Snyder
>>
>> Software Development, Financial Systems Team
>>
>> Whole Foods Market, HQ
>>
>> barron.snyder at wholefoods.com
>>
>>
>>
>> This email contains proprietary and confidential material for the 
>> sole use
>> of the intended recipient. Any review, use, distribution or 
>> disclosure by
>> others without the permission of the sender is strictly prohibited.  
>> If you
>> are not the intended recipient (or authorized to receive for the 
>> recipient),
>> please contact the sender by reply email and delete all copies of the
>> message.
>>
>>
>> _______________________________________________
>> Austin mailing list
>> Austin at pm.org
>> http://mail.pm.org/mailman/listinfo/austin
>>
>>
>
>
> -- 
> ****************************************************
> Whatever you do, take care of your shoes
> jayflaherty at gmail.com
> _______________________________________________
> Austin mailing list
> Austin at pm.org
> http://mail.pm.org/mailman/listinfo/austin
>
-----------------------------------------------------------------------
David H. Bluestein II
President & Lead Developer         dbii at interaction.net
ii, inc.                                                  
http://www.interaction.net
     -- Specializing in Interactive, Database Driven Websites --



More information about the Austin mailing list