Re: last regex question (for the evening)

2012-11-22 Thread shawn wilson
i think i got it working correctly. thanks for your help: my ($ip, $ident, $userid, $time, $cgi, $url, $proto, $status, $size_tx, $ref, $ua, $size_rx, $re_time) = /^ ([-0-9\.]+)\# ip address (\S+)\ # i

Re: last regex question (for the evening)

2012-11-22 Thread Shawn H Corey
Oops, I found an error my parser. Here's version 1.0.2: DATA_LOOP: while( my $line = ){ print $line; my @captured = ( '' ); my $inside = 0; CAPTURE_LOOP: while( 1 ){ if( $line =~ m{ \G ( [^"\\]+ | \\ ["\\] ) }gcx ){ $captured[-1] .= $1 if $inside; }elsif( $line =~ m{ \G \

Re: last regex question (for the evening)

2012-11-22 Thread Shawn H Corey
On Wed, 21 Nov 2012 20:54:29 -0500 shawn wilson wrote: > how do i capture all quoted strings? OK, I rewrote it as a simple parser: DATA_LOOP: while( my $line = ){ print $line; my @captured = ( '' ); my $inside = 0; CAPTURE_LOOP: while( 1 ){ if( $line =~ m{ \G ( [^"\\]+ | \\ ["\\

Re: last regex question (for the evening)

2012-11-21 Thread Shawn H Corey
On Wed, 21 Nov 2012 20:54:29 -0500 shawn wilson wrote: > to match - and sometimes there are spaces before the match, a '\' with > no '"', etc. I think you want something like: while( ){ my @captured = m{ \" ( [^"\\]* (?: \\ ["\\] [^"\\]* )* ) \" }gx; print; print "\t$_\n" for @captured

Re: last regex question (for the evening)

2012-11-21 Thread shawn wilson
oh, and just to be clear (since i suppose it wasn't by me saying that i was looking at the regexes in other modules to accomplish this) this is, as someone else (on this list) once told me "masturbation with code". i can do what i set off to accomplish but i just wanted more and it annoyed me that

Re: last regex question (for the evening)

2012-11-21 Thread shawn wilson
that's a pretty cool module - i especially like their regex with lookup table trick. however, since i've got a decently lengthy regex written to do what i want, and because i'm itching to know how to actually do this at this point (i'd really like to know what's wrong with the regex i posted as wel

Re: last regex question (for the evening)

2012-11-21 Thread Shawn H Corey
On Wed, 21 Nov 2012 20:54:29 -0500 shawn wilson wrote: > how do i capture all quoted strings? Get Regexp::Common from CPAN and read Regexp::Common::delimited. http://search.cpan.org/~abigail/Regexp-Common-2011121001/ -- Just my 0.0002 million dollars worth, Shawn Programming is

last regex question (for the evening)

2012-11-21 Thread shawn wilson
how do i capture all quoted strings? this gives an error: print "$str1\n"; ($one, $two) = $str1 =~/"([^(?:[^"]")]*)" (\d+)/; print "$one $two\n"; what i want is: $str1 = "\"something\" 444"; $str1 = "\"\\\"escaped quote\\\" 321"; $str1 = "\"\\\"esc quote\\\" other stuff\" 567"; to match - and s

Re: here doc/regex question

2012-09-27 Thread Matthias Leopold
Am 2012-09-27 13:16, schrieb Shlomi Fish: Hi Matthias, On Thu, 27 Sep 2012 12:50:56 +0200 Matthias Leopold wrote: hi, i'm using the example from man perlop for here docs with indentation i'm using vim syntax with "set list" and "set number lines" 1 ^I(my $quote =<<'^IFINIS') =~ s/^\s+//

Re: here doc/regex question

2012-09-27 Thread Shlomi Fish
Hi Matthias, On Thu, 27 Sep 2012 12:50:56 +0200 Matthias Leopold wrote: > hi, > > i'm using the example from man perlop for here docs with indentation > i'm using vim syntax with "set list" and "set number lines" > >1 ^I(my $quote = <<'^IFINIS') =~ s/^\s+//gm;$ >2 ^IThe Road goes ever

here doc/regex question

2012-09-27 Thread Matthias Leopold
hi, i'm using the example from man perlop for here docs with indentation i'm using vim syntax with "set list" and "set number lines" 1 ^I(my $quote = <<'^IFINIS') =~ s/^\s+//gm;$ 2 ^IThe Road goes ever on and on,$ 3 $ 4 ^I$ 5 ^Idown from the door where it began.$ 6 ^IFINIS$ why does

Re: regex question

2010-07-08 Thread Dr.Ruud
Shlomi Fish wrote: On Friday 02 Jul 2010 17:29:27 Dr.Ruud wrote: sdDirtySox wrote: I want to use a perl script that will look at all the files in a directory to find an instance of a function and replace it with another. I have the code in place to look at all the files in a directory and to

Re: regex question

2010-07-06 Thread Shlomi Fish
On Friday 02 Jul 2010 17:29:27 Dr.Ruud wrote: > sdDirtySox wrote: > > I want to use a perl script that will look at all the files in a > > directory to find an instance of a function and replace it with > > another. I have the code in place to look at all the files in a > > directory and to search

Re: regex question

2010-07-04 Thread Bo Jangles
Thanks for responding. I'll give it a try. On Jul 2, 5:10 am, jwkr...@shaw.ca ("John W. Krahn") wrote: > sdDirtySox wrote: > > Hi all, > > Hello, > > > I want to use a perl script that will look at all the files in a > > directory to find an instance of a function and replace it with > > another.

Re: regex question

2010-07-04 Thread Dr.Ruud
sdDirtySox wrote: I want to use a perl script that will look at all the files in a directory to find an instance of a function and replace it with another. I have the code in place to look at all the files in a directory and to search line by line, but I'm having problems with the regex to use.

Re: regex question

2010-07-02 Thread John W. Krahn
sdDirtySox wrote: Hi all, Hello, I want to use a perl script that will look at all the files in a directory to find an instance of a function and replace it with another. I have the code in place to look at all the files in a directory and to search line by line, but I'm having problems with

regex question

2010-07-02 Thread sdDirtySox
Hi all, I want to use a perl script that will look at all the files in a directory to find an instance of a function and replace it with another. I have the code in place to look at all the files in a directory and to search line by line, but I'm having problems with the regex to use. Example: s

Re: Regex question

2010-03-24 Thread Dr.Ruud
Bruce Ferrell wrote: if ( ! defined $username || ! $username =~ /[0-9]{10,11}/ ) { do something; } else { do something else; } if ( $username and $username =~ /\A[0-9]{10,11}\z/ ) { ...; } else { die; } -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@p

AW: Regex question

2010-03-24 Thread Thomas Bätzler
Bruce Ferrell wrote: > if ( ! defined $username || ! $username =~ /[0-9]{10,11}/ ) { > > do something; > > } else { > > do something else; > > } > > what that's supposed to do is this: > if it's blank or not 10 or 11 digits... > > The question is where is my understanding faulty or did I me

Re: Regex question

2010-03-24 Thread trapd00r
On 24/03/10 00:13 -0700, Bruce Ferrell wrote: if ( ! defined $username || ! $username =~ /[0-9]{10,11}/ ) { do something; } else { do something else; } what that's supposed to do is this: if it's blank or not 10 or 11 digits... The question is where is my understanding faulty or did I mess

Regex question

2010-03-24 Thread Bruce Ferrell
if ( ! defined $username || ! $username =~ /[0-9]{10,11}/ ) { do something; } else { do something else; } what that's supposed to do is this: if it's blank or not 10 or 11 digits... The question is where is my understanding faulty or did I mess up. Thanks in advance Bruce -- To unsubscri

Re: regex question

2009-12-22 Thread John W. Krahn
Parag Kalra wrote: You can try following: $_ =~ s/^\.(\s)+//g; You are using capturing parentheses but you are not using the results of that capture anywhere so why use them? You are using capturing parentheses in LIST context so even if there are multiple whitespace characters you are onl

Re: regex question

2009-12-22 Thread Parag Kalra
Thanks Philip for sharing this excellent piece of information. Cheers, Parag On Tue, Dec 22, 2009 at 8:17 PM, Philip Potter wrote: > 2009/12/22 Parag Kalra : > > You can try following: > > > > $_ =~ s/^\.(\s)+//g; > > This isn't quite right. > > There are two ways in which you might use this

Re: regex question

2009-12-22 Thread Shawn H Corey
Philip Potter wrote: > 2009/12/22 Parag Kalra : >> You can try following: >> >> $_ =~ s/^\.(\s)+//g; > > This isn't quite right. > > There are two ways in which you might use this substitution: either $_ > will contain a single line, or it will contain multiple lines. The > single line case might

Re: regex question

2009-12-22 Thread Philip Potter
2009/12/22 Parag Kalra : > You can try following: > > $_ =~ s/^\.(\s)+//g; This isn't quite right. There are two ways in which you might use this substitution: either $_ will contain a single line, or it will contain multiple lines. The single line case might look something like this: while (<>)

Re: regex question

2009-12-22 Thread Parag Kalra
You can try following: $_ =~ s/^\.(\s)+//g; Cheers, Parag On Tue, Dec 22, 2009 at 10:59 AM, Jim Green wrote: > Hi, > > I have a text file with lines like this > > > · Experience in C/C++ realtime system programming > > · Experience in ACE, FIX > > > Could anybody tell me whic

regex question

2009-12-22 Thread Jim Green
Hi, I have a text file with lines like this · Experience in C/C++ realtime system programming · Experience in ACE, FIX Could anybody tell me which regex to use to get rid of the dot and the leading spaces before each Line? Thanks for any help! Jim -- To unsubscribe, e-ma

Re: regex question

2009-12-21 Thread Jim Green
2009/12/22 Jim Gibson : > s/^\.\s*//; Thanks Jim, I will figure out as I read "learning perl". > > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > > -- To unsubscribe, e-mail: beginners-unsubscr

Re: regex question

2009-12-21 Thread Jim Gibson
At 11:49 PM -0600 12/21/09, Jim Green wrote: Hi, I have a text file with lines like this · Experience in C/C++ realtime system programming · Experience in ACE, FIX Could anybody tell me which regex to use to get rid of the dot and the leading spaces before each Line? s/^\.

Re: regex question

2009-12-21 Thread Jim Green
2009/12/21 Uri Guttman : >> "JG" == Jim Green writes: > >  JG> I have a text file with lines like this > > >  JG> ·         Experience in C/C++ realtime system programming > >  JG> ·         Experience in ACE, FIX > > >  JG> Could anybody tell me which regex to use to get rid of the dot and th

Re: regex question

2009-12-21 Thread Uri Guttman
> "JG" == Jim Green writes: JG> I have a text file with lines like this JG> · Experience in C/C++ realtime system programming JG> · Experience in ACE, FIX JG> Could anybody tell me which regex to use to get rid of the dot and the JG> leading spaces before each L

regex question

2009-12-21 Thread Jim Green
Hi, I have a text file with lines like this · Experience in C/C++ realtime system programming · Experience in ACE, FIX Could anybody tell me which regex to use to get rid of the dot and the leading spaces before each Line? Thanks for any help! Jim -- To unsubscribe, e-mail

Re: regex question

2009-11-11 Thread Jeremiah Foster
On Nov 9, 2009, at 16:25, axr0284 wrote: > Hi, > I am completely stumped with how to proceed with this. > I have a program where the user inputs a path to a file. This is under > windows xp > > The path can be relative > ..\..\..\synthesis\int_code.psm > .\program\synthesis\int_code.psm > > or

Re: regex question

2009-11-09 Thread Jay Savage
On Mon, Nov 9, 2009 at 10:25 AM, axr0284 wrote: > Hi, >  I am completely stumped with how to proceed with this. > I have a program where the user inputs a path to a file. This is under > windows xp > > The path can be relative > ..\..\..\synthesis\int_code.psm > .\program\synthesis\int_code.psm >

regex question

2009-11-09 Thread axr0284
Hi, I am completely stumped with how to proceed with this. I have a program where the user inputs a path to a file. This is under windows xp The path can be relative ..\..\..\synthesis\int_code.psm .\program\synthesis\int_code.psm or absolute c:\command\tool\program\synthesis\int_code.psm I do

Re: regex question

2009-09-15 Thread Uri Guttman
> "GM" == Gregory Machin writes: GM> Thanks for the help .. knowing the anchor thing help me. if you not GM> sure what ur looking for or what it call you end up with the wrong GM> thing. did you read my post? if you had a clue about the digits starting at the beginning of the string, t

Re: regex question

2009-09-15 Thread Gregory Machin
Thanks for the help .. knowing the anchor thing help me. if you not sure what ur looking for or what it call you end up with the wrong thing. On Tue, Sep 15, 2009 at 10:21 AM, Tim Bowden wrote: > On Tue, 2009-09-15 at 10:10 +0200, Gregory Machin wrote: >> Any numbers, but only 3 digits in the str

Re: regex question

2009-09-15 Thread Tim Bowden
On Tue, 2009-09-15 at 10:10 +0200, Gregory Machin wrote: > Any numbers, but only 3 digits in the string. > > I'm filtering out local extention numbers from phone numbers > > Where in the log the extension is 104 and the phone number would be > something like PSTN0/2-0115070545. All the stuff I ha

Re: regex question

2009-09-15 Thread Gregory Machin
Any numbers, but only 3 digits in the string. I'm filtering out local extention numbers from phone numbers Where in the log the extension is 104 and the phone number would be something like PSTN0/2-0115070545. All the stuff I have tried have returned would return both the extension number and 3

Re: regex question

2009-09-15 Thread Tim Bowden
On Tue, 2009-09-15 at 09:30 +0200, Gregory Machin wrote: > Hi > > I'm look for code example that will only select a string containing 3 > digits .. The string cant be less than 3 digit , can't be more than 3 > and can't contain any other characters. > > I have googled and found code that will fin

Re: regex question

2009-09-15 Thread Uri Guttman
> "GM" == Gregory Machin writes: GM> I'm look for code example that will only select a string containing 3 GM> digits .. The string cant be less than 3 digit , can't be more than 3 GM> and can't contain any other characters. that is called containing exactly three digits. you spent way

regex question

2009-09-15 Thread Gregory Machin
Hi I'm look for code example that will only select a string containing 3 digits .. The string cant be less than 3 digit , can't be more than 3 and can't contain any other characters. I have googled and found code that will find 3 consecutive digits within a string or at the beginning. Any ideas

RE: Simple regex question

2009-05-19 Thread Ajay Kumar
: beginners@perl.org Subject: Re: Simple regex question You wrote on 05/19/2009 03:18 PM: > Simple question for the regEXperts out there... > > I have a string that is always in the format: a.nn+x.y > > a is always 5 chars > n can be 1 or 2 digits > x can be +/- (with sign), 1-4

Re: Simple regex question

2009-05-19 Thread John W. Krahn
Dan Fish wrote: Simple question for the regEXperts out there... I have a string that is always in the format: a.nn+x.y a is always 5 chars [a-zA-Z0-9]{5} n can be 1 or 2 digits [0-9]{1,2} x can be +/- (with sign), 1-4 digits [-+][0-9]{1,4} y is always positive (no sign), 1

Re: Simple regex question

2009-05-19 Thread John W. Krahn
Chas. Owens wrote: On Tue, May 19, 2009 at 09:55, Alexander Koenig wrote: snip ($a,$n,$x,$y)) = $item =~ /(.{5})\.(\d\d?)[-+](\d{1,4})\.(\d{1,4})/; snip As of Perl 5.8 \d no longer matches [0-9]. ^ As of Perl 5.8 \d no longer matches only [0-9].

Re: Simple regex question

2009-05-19 Thread John W. Krahn
Dan Fish wrote: Simple question for the regEXperts out there... I have a string that is always in the format: a.nn+x.y a is always 5 chars [a-zA-Z0-9]{5} n can be 1 or 2 digits [0-9]{1,2} x can be +/- (with sign), 1-4 digits [-+][0-9]{1,4} y is always positive (no sign), 1

Re: Simple regex question

2009-05-19 Thread Chas. Owens
On Tue, May 19, 2009 at 10:21, Alexander Koenig wrote: > Chas. Owens wrote on 05/19/2009 04:02 PM: > >>> ($a,$n,$x,$y)) = $item =~ /(.{5})\.(\d\d?)[-+](\d{1,4})\.(\d{1,4})/; >> snip >> >> As of Perl 5.8 \d no longer matches [0-9].  It now matches any UNICODE >> character that has the digit propert

Re: Simple regex question

2009-05-19 Thread Alexander Koenig
Chas. Owens wrote on 05/19/2009 04:02 PM: >> ($a,$n,$x,$y)) = $item =~ /(.{5})\.(\d\d?)[-+](\d{1,4})\.(\d{1,4})/; > snip > > As of Perl 5.8 \d no longer matches [0-9]. It now matches any UNICODE > character that has the digit property. This includes characters such > as "\x{1815}" (MONGOLIAN DI

RE: Simple regex question

2009-05-19 Thread Dan Fish
> > Simple question for the regEXperts out there... > > > > I have a string that is always in the format:  a.nn+x.y > > > > a is always 5 chars > > n can be 1 or 2 digits > > x can be +/- (with sign), 1-4 digits > > y is always positive (no sign), 1-4 digits > snip > > What do you mean by char

RE: Simple regex question

2009-05-19 Thread Andrew Curry
A crude one ($part,$unit,$x,$y,$xlen,$ylen) = ($1,$2,$3,length($4),length($5)) if ($string =~ /(^\S{5})\.(\d{2})([+-])(\d+)\.(\d+)$/); -Original Message- From: Dan Fish [mailto:d...@ninemoons.com] Sent: 19 May 2009 14:18 To: beginners@perl.org Subject: Simple regex question Simple

Re: Simple regex question

2009-05-19 Thread Chas. Owens
On Tue, May 19, 2009 at 09:55, Alexander Koenig wrote: snip > ($a,$n,$x,$y)) = $item =~ /(.{5})\.(\d\d?)[-+](\d{1,4})\.(\d{1,4})/; snip As of Perl 5.8 \d no longer matches [0-9]. It now matches any UNICODE character that has the digit property. This includes characters such as "\x{1815}" (MONGO

Re: Simple regex question

2009-05-19 Thread Chas. Owens
On Tue, May 19, 2009 at 09:18, Dan Fish wrote: > Simple question for the regEXperts out there... > > I have a string that is always in the format:  a.nn+x.y > > a is always 5 chars > n can be 1 or 2 digits > x can be +/- (with sign), 1-4 digits > y is always positive (no sign), 1-4 digits snip

Re: Simple regex question

2009-05-19 Thread Alexander Koenig
You wrote on 05/19/2009 03:18 PM: > Simple question for the regEXperts out there... > > I have a string that is always in the format: a.nn+x.y > > a is always 5 chars > n can be 1 or 2 digits > x can be +/- (with sign), 1-4 digits > y is always positive (no sign), 1-4 digits The best I ca

Simple regex question

2009-05-19 Thread Dan Fish
Simple question for the regEXperts out there... I have a string that is always in the format: a.nn+x.y a is always 5 chars n can be 1 or 2 digits x can be +/- (with sign), 1-4 digits y is always positive (no sign), 1-4 digits Some examples: A123C.11+002.001 FC32G.2-1.0

Re: quick regex question

2009-03-25 Thread Telemachus
On Wed Mar 25 2009 @ 3:10, Chas. Owens wrote: > On Wed, Mar 25, 2009 at 13:21, Telemachus wrote: > snip > >    my $string2 = 'remove-all-this (Keep this) remove this too'; > > > >    $string2 =~ s/.*\((.*)\)/$1/; > snip > > If $string2 may contain more than one pair of parentheses, you will want

Re: quick regex question

2009-03-25 Thread Chas. Owens
On Wed, Mar 25, 2009 at 13:21, Telemachus wrote: snip >    my $string2 = 'remove-all-this (Keep this) remove this too'; > >    $string2 =~ s/.*\((.*)\)/$1/; snip If $string2 may contain more than one pair of parentheses, you will want to say $string2 =~ s/.*\((.*?)\)/$1/; or $string2 =~ s/.*\(

Re: quick regex question

2009-03-25 Thread Gunnar Hjalmarsson
Rick Bragg wrote: I need a quick regex to strip out the following: Never heard of that. What is a quick regex? -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.o

Re: quick regex question

2009-03-25 Thread Telemachus
On Wed Mar 25 2009 @ 12:19, Rodrick Brown wrote: > On Wed, Mar 25, 2009 at 12:00 PM, Rick Bragg wrote: > > I need a quick regex to strip out the following: > > > > example: > > change "remove-all-this (Keep This)" into just "Keep This" > > > > $s =~ s/.*\((.*)\)/$1/; > > > something like: > > s/

Re: quick regex question

2009-03-25 Thread Rodrick Brown
On Wed, Mar 25, 2009 at 12:00 PM, Rick Bragg wrote: > I need a quick regex to strip out the following: > > example: > change "remove-all-this (Keep This)" into just "Keep This" > $s =~ s/.*\((.*)\)/$1/; > something like: > s/ beginning of line up to and including the first ( //g > s/ starting fr

quick regex question

2009-03-25 Thread Rick Bragg
I need a quick regex to strip out the following: example: change "remove-all-this (Keep This)" into just "Keep This" something like: s/ beginning of line up to and including the first ( //g s/ starting from and including first ) to end of line //g Can anyone help with this quick line or 2? Than

Re: quick regex question

2009-01-09 Thread Gunnar Hjalmarsson
Chris Knipe wrote: (Really just need to get $interface name and $signal)... Then you may prefer a list slice. my ($interface, $signal) = (split ' ', $Line)[1,5]; -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org

Re: quick regex question

2009-01-09 Thread Gunnar Hjalmarsson
Chris Knipe wrote: Paolo Gianrossi wrote: Could maybe a simple split(/\s+/ $Line, 7); work? Almost, but we're not *quite* there yet... ... I'm not sure why I am required to have 9 fields in the split to get the values now... It appears from your initial post as if there is a leading space b

Re: quick regex question

2009-01-09 Thread Paolo Gianrossi
Chris Knipe ha scritto: >>> # INTERFACE >>> RADIO-NAME MAC-ADDRESS AP SIGNAL-STRENGTH TX-RATE UPTIME >>> 0 interface_name radio >>> 00:0C:42:1F:2C:8D yes -63...@18mbps 9Mbps 2h2m38s >>> >>> I'm looking for a >>> foreach my $Line (@

Re: quick regex question

2009-01-09 Thread John W. Krahn
Chris Knipe wrote: Hi, Hello, I have two lines (well, 1 line is headers, then there follows a range of data)... # INTERFACE RADIO-NAME MAC-ADDRESS AP SIGNAL-STRENGTH TX-RATE UPTIME 0 interface_name radio 00:0C:42:1F:2C:8D yes -

RE: quick regex question

2009-01-09 Thread Chris Knipe
> > > > # INTERFACE > > RADIO-NAME MAC-ADDRESS AP SIGNAL-STRENGTH TX-RATE UPTIME > > 0 interface_name radio > > 00:0C:42:1F:2C:8D yes -63...@18mbps 9Mbps 2h2m38s > > > > I'm looking for a > > foreach my $Line (@Output) { > > my (

Re: quick regex question

2009-01-09 Thread Paolo Gianrossi
Chris Knipe ha scritto: > Hi, > > I have two lines (well, 1 line is headers, then there follows a range of > data)... > > # INTERFACE > RADIO-NAME MAC-ADDRESS AP SIGNAL-STRENGTH TX-RATE UPTIME > 0 interface_name radio > 00:0C:42:1F:2C

quick regex question

2009-01-09 Thread Chris Knipe
Hi, I have two lines (well, 1 line is headers, then there follows a range of data)... # INTERFACE RADIO-NAME MAC-ADDRESS AP SIGNAL-STRENGTH TX-RATE UPTIME 0 interface_name radio 00:0C:42:1F:2C:8D yes -63...@18mbps 9Mbps 2h2m38s

anagrams (was: Re: Regex question.)

2008-07-05 Thread Dr.Ruud
Gunwant Singh schreef: > I have a query regarding regexes. No, you don't. > I am to match only one specific word in a wordlist which has only > those alphabets which it contains and none other than that. To do that, you can use regexes, but you don't need to. > My Wordlist contains: > > alph

Regex question.

2008-07-04 Thread Gunwant Singh
Hi all, Thanks for all the help provided so far in my earlier queries. I have a query regarding regexes. I am to match only one specific word in a wordlist which has only those alphabets which it contains and none other than that. For example: My Wordlist contains: alpha alpha1 beta betaze

Re: regex question matching dates

2008-05-29 Thread Richard Lee
John W. Krahn wrote: } elsif ( $ARGV[0] =~ m/\b2008(0[1-9]|1[12])(0[1-9]|1[0-9]|2[0-9]|3[01])([01][0-9]|2[0-3])\b/ ) { ^ So you don't want to test for October? John fixed now. thanks!! } elsif ( $ARGV[0] =~ m/\b2008(0[1-9]|1[012])(0[1-9]|1[0-9]|2[0-9]|3[01])([01][

Re: regex question matching dates

2008-05-28 Thread John W. Krahn
Richard Lee wrote: John W. Krahn wrote: Richard Lee wrote: given then ARGV[0] is 2008052803, why woulnd't below regex match them?? 2008052803 is a ten digit number. } elsif ( $ARGV[0] =~ m/\b2008[01][1-31]([01][0-9]|2[0-3])\b/ ) { Your pattern matches eight digits with a \b word boundary

Re: regex question matching dates

2008-05-28 Thread Richard Lee
John W. Krahn wrote: Richard Lee wrote: given then ARGV[0] is 2008052803, why woulnd't below regex match them?? 2008052803 is a ten digit number. } elsif ( $ARGV[0] =~ m/\b2008[01][1-31]([01][0-9]|2[0-3])\b/ ) { Your pattern matches eight digits with a \b word boundary at each end so it

Re: regex question matching dates

2008-05-28 Thread John W. Krahn
John W. Krahn wrote: Richard Lee wrote: @array = qx#ls -tr $directory/$ARGV[0]*#; Why not do that directly in perl: @array = map $_->[0], sort { $a->[1] <=> $b->[1] } map [ $_, -M ], glob "$directory/$ARGV[0]*"; Sorry, that should be: @array = map $_->[0], sort { $b->[1] <

Re: regex question matching dates

2008-05-28 Thread John W. Krahn
Richard Lee wrote: given then ARGV[0] is 2008052803, why woulnd't below regex match them?? 2008052803 is a ten digit number. } elsif ( $ARGV[0] =~ m/\b2008[01][1-31]([01][0-9]|2[0-3])\b/ ) { Your pattern matches eight digits with a \b word boundary at each end so it will never match a ten

regex question matching dates

2008-05-28 Thread Richard Lee
given then ARGV[0] is 2008052803, why woulnd't below regex match them?? } elsif ( $ARGV[0] =~ m/\b2008[01][1-31]([01][0-9]|2[0-3])\b/ ) { @array = qx#ls -tr $directory/$ARGV[0]*#; #2008052803 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED

Re: regex question

2008-04-25 Thread David Nicholas Kayal
Thank you. On Fri, 25 Apr 2008, J. Peng wrote: On Fri, Apr 25, 2008 at 12:47 AM, David Nicholas Kayal <[EMAIL PROTECTED]> wrote: why is the first one true? check 'perldoc perlre' : The following standard quantifiers are recognized: * Match 0 or more times \d* me

Re: regex question

2008-04-25 Thread J. Peng
On Fri, Apr 25, 2008 at 12:47 AM, David Nicholas Kayal <[EMAIL PROTECTED]> wrote: > > why is the first one true? > check 'perldoc perlre' : The following standard quantifiers are recognized: * Match 0 or more times \d* means 0 or more numbers. -- J. Peng - QQMail Op

regex question

2008-04-25 Thread David Nicholas Kayal
[EMAIL PROTECTED] quick_test]$ cat test_regex.pl #!/usr/bin/perl -w use strict; my $line = "test_text"; if($line =~ m/^\d*/) { print "true\n"; } else { print "false\n"; } if($line =~ m/^\d/) { print "true\n"; } else { print "false\n"; } [EMAIL PROTECTED] quick_t

Re: basic regex question

2007-10-11 Thread Matthew Whipple
The primary problem would be that you're match seems a bit backwards. Try "if ($line =~ m/$file/)" which will cut through any extra formatting output by dir. Jim wrote: > Hi Everyone, > > I am trying to match file & subdir names from a back tic generated list. > I never find anything and there ar

Re: basic regex question

2007-10-10 Thread Panda-X
2007/10/11, Jim <[EMAIL PROTECTED]>: > > Hi Everyone, > > I am trying to match file & subdir names from a back tic generated list. > I never find anything and there are files in the directory with a correct > name. > but if i make up a list to use as filenames > it works as i expect ... any insight

basic regex question

2007-10-10 Thread Jim
Hi Everyone, I am trying to match file & subdir names from a back tic generated list. I never find anything and there are files in the directory with a correct name. but if i make up a list to use as filenames it works as i expect ... any insight greatly appreciated thanks Jim #!/usr/bin/perl

Re: YARQ: Yet Another Regex Question

2007-05-16 Thread Mathew
Chas Owens wrote: > On 5/16/07, Mathew <[EMAIL PROTECTED]> wrote: > snip >> What does gr() do? >> >> Mathew >> > > qr not gr. It is the quote regex operator. > > from perldoc perlop > qr/STRING/imosx > This operator quotes (and possibly compiles) its STRING as a >

Re: YARQ: Yet Another Regex Question

2007-05-16 Thread Jeff Pang
Mathew 写道: What does gr() do? It's "qr" not "gr". See "perldoc perlop" and look for "qr/STRING/imosx". -- http://home.arcor.de/jeffpang/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: YARQ: Yet Another Regex Question

2007-05-16 Thread Chas Owens
On 5/16/07, Mathew <[EMAIL PROTECTED]> wrote: snip What does gr() do? Mathew qr not gr. It is the quote regex operator. from perldoc perlop qr/STRING/imosx This operator quotes (and possibly compiles) its STRING as a regular expression. STRING is interpola

Re: YARQ: Yet Another Regex Question

2007-05-16 Thread Mathew
Chas Owens wrote: > On 5/16/07, Mathew Snyder <[EMAIL PROTECTED]> wrote: >> I have a trouble ticket application that uses a regex to find a piece of >> information in an incoming email and auto populate a field if it is >> found. The >> line it will be looking for is >> CUSTOMER ENVIRONMENT cust

Re: YARQ: Yet Another Regex Question

2007-05-16 Thread Chas Owens
On 5/16/07, Mathew Snyder <[EMAIL PROTECTED]> wrote: I have a trouble ticket application that uses a regex to find a piece of information in an incoming email and auto populate a field if it is found. The line it will be looking for is CUSTOMER ENVIRONMENT customer_name where customer_name will

YARQ: Yet Another Regex Question

2007-05-16 Thread Mathew Snyder
I have a trouble ticket application that uses a regex to find a piece of information in an incoming email and auto populate a field if it is found. The line it will be looking for is CUSTOMER ENVIRONMENT customer_name where customer_name will never have a space making it one word. If I just want

Re: regex question

2007-05-15 Thread rob . dixon
John W. Krahn writes: Tom Allison wrote: How do I pull all the words from a line between the two words 'from' and 'by' when I have NO IDEA what's in there, but I know they are all in one line. To make it more difficult. 'by' is optional... Like this: from..by.. or from..

Re: regex question

2007-05-14 Thread Chas Owens
On 5/14/07, Jeff Pang <[EMAIL PROTECTED]> wrote: snip Maybe a space following the "by" is needed? :) snip This what the word boundary character class is for perl -le' for ( "abc from to the word by and the end", "abc from to the end", "abc from this byebye to this") { print $1 if /from(.*?(?

Re: regex question

2007-05-14 Thread Igor Sutton Lopes
Hi, On May 14, 2007, at 11:50 PM, Tom Allison wrote: yitzle wrote: # Requires "by": $line = "daffromHello Worldby"; $line =~ /from(.*)(by)/; print $1; Not sure about making it optional. Can always check if you got "" and then try without the "by" the .* pulls in too much. I'm going to have

Re: regex question

2007-05-14 Thread Jeff Pang
John W. Krahn 写道: $ perl -le' for ( "abc from to the word by and the end", "abc from to the end" ) { print $1 if /from(.*?(?=by)|.*)/; } ' But this coundn't handle this case: $string = "abc from to the word byebye..."; Maybe a space following the "by" is needed? :) -- To unsubscrib

Re: regex question

2007-05-14 Thread John W. Krahn
Tom Allison wrote: > How do I pull all the words from a line between the two words 'from' and > 'by' when I have NO IDEA what's in there, but I know they are all in one > line. > > To make it more difficult. 'by' is optional... > > Like this: > > from..by.. > or > from.. > > I want

Re: regex question

2007-05-14 Thread Tom Allison
yitzle wrote: # Requires "by": $line = "daffromHello Worldby"; $line =~ /from(.*)(by)/; print $1; Not sure about making it optional. Can always check if you got "" and then try without the "by" the .* pulls in too much. I'm going to have to back up and try this again. But I think it's late.

Re: regex question

2007-05-14 Thread yitzle
# Requires "by": $line = "daffromHello Worldby"; $line =~ /from(.*)(by)/; print $1; Not sure about making it optional. Can always check if you got "" and then try without the "by" On 5/14/07, Tom Allison <[EMAIL PROTECTED]> wrote: How do I pull all the words from a line between the two words 'f

regex question

2007-05-14 Thread Tom Allison
How do I pull all the words from a line between the two words 'from' and 'by' when I have NO IDEA what's in there, but I know they are all in one line. To make it more difficult. 'by' is optional... Like this: from..by.. or from.. I want all the stuff inside. Initially I'm think

Re: split w. regex question/problem

2007-02-07 Thread Rob Dixon
John W. Krahn wrote: Rob Dixon wrote: John W. Krahn wrote: Gauthier, Dave wrote: Getting unwanted list elements when using split with regex. Here's an example $str = "abc=In"; @arr = split(/[a-zA-Z0-9]/,$str); foreach $a (@arr) {print "$a\n";} I get... <> <> <> <=> ^ ^ ^ ^

Re: split w. regex question/problem

2007-02-04 Thread Dr.Ruud
"John W. Krahn" schreef: > split Splits the string EXPR into a list of strings and returns > that list. By default, empty leading fields are > preserved, For which meanings of 'default'? :) perl -wle ' $_ = " a b c "; @x = split; print scalar @x; ' 3 -- Aff

Re: split w. regex question/problem

2007-02-03 Thread John W. Krahn
Rob Dixon wrote: > John W. Krahn wrote: >> >> Gauthier, Dave wrote: >>> >>> Getting unwanted list elements when using split with regex. Here's an >>> example >>> >>> $str = "abc=In"; >>> @arr = split(/[a-zA-Z0-9]/,$str); >>> foreach $a (@arr) >>> {print "$a\n";} >>> >>> I get... >>> >>> <> <

Re: split w. regex question/problem

2007-02-03 Thread Rob Dixon
John W. Krahn wrote: > Gauthier, Dave wrote: >> Getting unwanted list elements when using split with regex. Here's an example $str = "abc=In"; @arr = split(/[a-zA-Z0-9]/,$str); foreach $a (@arr) {print "$a\n";} I get... <> <> <> <=> If I change "abc=In" to "abcdef=In", I get 6 un

Re: split w. regex question/problem

2007-02-02 Thread John W. Krahn
Gauthier, Dave wrote: > Getting unwanted list elements when using split with regex. Here's an > example > > $str = "abc=In"; > @arr = split(/[a-zA-Z0-9]/,$str); > foreach $a (@arr) > {print "$a\n";} > > I get... > > <> > <> > <> > <=> > > If I change "abc=In" to "abcdef=In", I get 6 u

  1   2   3   >