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: yet another regex

2007-05-12 Thread Dr.Ruud
Corrected header line: Newsgroups: perl.beginners,perl.beginners Chas Owens wrote: > In all of the corrections I totally missed that I had left caps-lock > on after the LOOP tag. Sigh, I obviously need more caffeine. I also > could not remember if the print was in a continue block or not.

Re: yet another regex

2007-05-11 Thread Steve Finkelstein
Chas, Tom, Martin -- thank you for all of your expertise and valuable insight to helping me understand the logic in the previous regex. As for where I saw this code, a friend of mine works for a company that has a unique approach of attracting coders. And I thought it might be a unique way of pote

Re: yet another regex

2007-05-11 Thread Tom Phoenix
On 5/11/07, Chas Owens <[EMAIL PROTECTED]> wrote: Beyond obfuscation, I can only think of one reason to write something like that: un-tainting. But even then it is bad regex for that since it doesn't validate anything. And the only thing that is untainted is the last digit found in the target

Re: yet another regex

2007-05-11 Thread Chas Owens
On 5/11/07, Tom Phoenix <[EMAIL PROTECTED]> wrote: On 5/11/07, Steve Finkelstein <[EMAIL PROTECTED]> wrote: > sflinux themes # echo 500 | perl -ple 's|(\d)|length(9 x $1)|eg;' > 500 > essentially, (\d) should match just the '5' in 500. that puts $1 == the > literal 5. so you take length(9 x 5)

Re: yet another regex

2007-05-11 Thread Tom Phoenix
On 5/11/07, Steve Finkelstein <[EMAIL PROTECTED]> wrote: sflinux themes # echo 500 | perl -ple 's|(\d)|length(9 x $1)|eg;' 500 essentially, (\d) should match just the '5' in 500. that puts $1 == the literal 5. so you take length(9 x 5) which is nine repeated 5 times, and the length of that is

Re: yet another regex

2007-05-11 Thread Chas Owens
On 5/11/07, John W. Krahn <[EMAIL PROTECTED]> wrote: snip LOOP: while ( <> ) { # case matters - there is no WHILE snip In all of the corrections I totally missed that I had left caps-lock on after the LOOP tag. Sigh, I obviously need more caffeine. I also could not remember if the print was

Re: yet another regex

2007-05-11 Thread John W. Krahn
Chas Owens wrote: > On 5/11/07, Chas Owens <[EMAIL PROTECTED]> wrote: >> On 5/11/07, Chas Owens <[EMAIL PROTECTED]> wrote: >> > On 5/11/07, Steve Finkelstein <[EMAIL PROTECTED]> wrote: >> > > Oh, so it goes through each and every character in the original >> string >> > > passed. I thought it takes

Re: yet another regex

2007-05-11 Thread Martin Barth
perldoc perlrun *g* -p causes Perl to assume the following loop around your program, which makes it iterate over filename arguments somewhat like sed: LINE: while (<>) { ... # your program goes here } continue

Re: yet another regex

2007-05-11 Thread Chas Owens
On 5/11/07, Chas Owens <[EMAIL PROTECTED]> wrote: On 5/11/07, Chas Owens <[EMAIL PROTECTED]> wrote: > On 5/11/07, Steve Finkelstein <[EMAIL PROTECTED]> wrote: > > Oh, so it goes through each and every character in the original string > > passed. I thought it takes in the string as one entity and

Re: yet another regex

2007-05-11 Thread Chas Owens
On 5/11/07, Chas Owens <[EMAIL PROTECTED]> wrote: On 5/11/07, Steve Finkelstein <[EMAIL PROTECTED]> wrote: > Oh, so it goes through each and every character in the original string > passed. I thought it takes in the string as one entity and just captures > the first digit it can. > > Does -p make

Re: yet another regex

2007-05-11 Thread Chas Owens
On 5/11/07, Steve Finkelstein <[EMAIL PROTECTED]> wrote: Oh, so it goes through each and every character in the original string passed. I thought it takes in the string as one entity and just captures the first digit it can. Does -p make it iterate over each character? No, the -ple causes it t

Re: yet another regex

2007-05-11 Thread Martin Barth
On Fri, 11 May 2007 18:24:14 -0400 Steve Finkelstein <[EMAIL PROTECTED]> wrote: > Oh, so it goes through each and every character in the original string > passed. I thought it takes in the string as one entity and just captures > the first digit it can. > > Does -p make it iterate over each chara

Re: yet another regex

2007-05-11 Thread Steve Finkelstein
Oh, so it goes through each and every character in the original string passed. I thought it takes in the string as one entity and just captures the first digit it can. Does -p make it iterate over each character? Martin Barth wrote: > On Fri, 11 May 2007 17:50:41 -0400 > Steve Finkelstein <[EMAIL

Re: yet another regex

2007-05-11 Thread Chas Owens
On 5/11/07, Steve Finkelstein <[EMAIL PROTECTED]> wrote: Yep, I'm stumped on what appears to be simple. Would anyone care to explain the following? sflinux themes # echo 500 | perl -ple 's|(\d)|length(9 x $1)|eg;' 500 essentially, (\d) should match just the '5' in 500. that puts $1 == the lite

Re: yet another regex

2007-05-11 Thread Martin Barth
On Fri, 11 May 2007 17:50:41 -0400 Steve Finkelstein <[EMAIL PROTECTED]> wrote: > echo 500 | perl -ple 's|(\d)|length(9 x $1)|eg;' no you're wrong: s///g <- matches 5 first. length(9x5) == 5, thats true but now next digit! 0 -> length ( 9 x 0 ) == length("") == 0 same again -- To unsubsc

yet another regex

2007-05-11 Thread Steve Finkelstein
Yep, I'm stumped on what appears to be simple. Would anyone care to explain the following? sflinux themes # echo 500 | perl -ple 's|(\d)|length(9 x $1)|eg;' 500 essentially, (\d) should match just the '5' in 500. that puts $1 == the literal 5. so you take length(9 x 5) which is nine repeated 5 t

Re: Yet Another Regex Problem

2004-06-08 Thread Ramprasad A Padmanabhan
CHange your regex to /http(s)*:\/\/.*?\s/ To see the docs perldoc perlre ... look for greedy HTH Ram On Tue, 2004-06-08 at 16:15, Francesco del Vecchio wrote: > Hi guyz, > > this regex are goin' to drive me crazy! > > My problem is: > > I have to find URLs in a text file (so, cannot use LW

Re: Yet Another Regex Problem

2004-06-08 Thread Jeff 'japhy' Pinyan
On Jun 8, Francesco del Vecchio said: >I have to find URLs in a text file (so, cannot use LWP or HTML parser) I'm curious why you can't use a module to extract URLs, but I'll continue anyway. >/(http.:\/\/.*\s)/ That regex is broken in a few ways. First, it does NOT match 'http:', it only matc

Yet Another Regex Problem

2004-06-08 Thread Francesco del Vecchio
Hi guyz, this regex are goin' to drive me crazy! My problem is: I have to find URLs in a text file (so, cannot use LWP or HTML parser) I've tried with something like /(http.:\/\/.*\s)/ willing to find anything starting with http/https with "//:" and catching everything up to a space or newli