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

Re: Quick regex question

2006-01-24 Thread John W. Krahn
Chris wrote: > Hi list, Hello, > I am not sure if there is a proper name for this but was having some > difficulty searching for it. > > Basically I have data in a file that is between two different > characters, for example: > > # data data > data > data data data * > # more dataaa > mor *

Re: Quick regex question

2006-01-24 Thread John Doe
Chris am Dienstag, 24. Januar 2006 22.35: > Hi list, > > I am not sure if there is a proper name for this but was having some > difficulty searching for it. > > Basically I have data in a file that is between two different > characters, for example: > > # data data > data > data data data * > # mor

Re: Quick regex question

2006-01-24 Thread Chas Owens
On 1/24/06, Chris <[EMAIL PROTECTED]> wrote: > Hi list, > > I am not sure if there is a proper name for this but was having some > difficulty searching for it. > > Basically I have data in a file that is between two different > characters, for example: > > # data data > data > data data data * > #

Quick regex question

2006-01-24 Thread Chris
Hi list, I am not sure if there is a proper name for this but was having some difficulty searching for it. Basically I have data in a file that is between two different characters, for example: # data data data data data data * # more dataaa mor * Basically I want to slurp that file in, the

Re: quick regex question

2005-03-31 Thread John W. Krahn
Offer Kaye wrote: On Thu, 31 Mar 2005 13:43:14 -0800, John W. Krahn wrote: Ah, but there is an important difference - in all the cases I wrote, the characters following the '@' sign could not be a legal variable name, $ perl -le' @) = qw/ a b c d /; print for @) ' Educational thread, this :-) perld

Re: quick regex question

2005-03-31 Thread Offer Kaye
On Thu, 31 Mar 2005 13:43:14 -0800, John W. Krahn wrote: > > Ah, but there is an important difference - in all the cases I wrote, > > the characters following the '@' sign could not be a legal variable > > name, > > $ perl -le' @) = qw/ a b c d /; print for @) ' Educational thread, this :-) > >

Re: quick regex question

2005-03-31 Thread John W. Krahn
Offer Kaye wrote: On Thu, 31 Mar 2005 12:16:21 -0800, John W. Krahn wrote: And yet in your examples you use @ in double quoted strings four times without escaping it (hint: m// and s/// interpolate like double quoted strings.) Ah, but there is an important difference - in all the cases I wrote, th

Re: quick regex question

2005-03-31 Thread Offer Kaye
On Thu, 31 Mar 2005 12:16:21 -0800, John W. Krahn wrote: > > Using the same regular expression twice is redundant. > 1 while $str =~ s/(?<=\@)(.+?)_/$1./; > Beautiful! But also a bit mind bending. I see code like this and I think - "too clever". It's not easy, I think, to understand at once what

Re: quick regex question

2005-03-31 Thread Jeff 'japhy' Pinyan
On Mar 31, Ramprasad A Padmanabhan said: $str = "[EMAIL PROTECTED]"; Should become [EMAIL PROTECTED] I'd use index() and substr(): if ((my $p = index($str, '@')) > -1) { substr($str, $p) =~ tr/_/./ } -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734

Re: quick regex question

2005-03-31 Thread John W. Krahn
Offer Kaye wrote: Here are 2 other methods, just for the heck of it :-) # Method 1 my $str = '[EMAIL PROTECTED]'; my ($part1,$part2) = split /@/, $str; $part2 =~ s/_/./g; $str = $part1."@".$part2; print "$str\n"; # Method 2 my $str = '[EMAIL PROTECTED]'; while ($str =~ m/(?<=@).+?_/) { $str =~ s

Re: quick regex question

2005-03-31 Thread Abhishek Dave
ay, March 31, 2005 3:13 PM Subject: quick regex question > Hi, > > I want to run a substitution for all instances of "_" with "." after > '@' in a string but "_" before "@" should not be touched. > > eg > $str = "[EM

Re: quick regex question

2005-03-31 Thread Offer Kaye
On Thu, 31 Mar 2005 02:08:22 -0800, John W. Krahn wrote: > > $ perl -le' > my $str = q/[EMAIL PROTECTED]/; > $str =~ s/([EMAIL PROTECTED])/($a = $1) =~ tr|_|.|; $a/e; > print $str; > ' > [EMAIL PROTECTED] > > $ perl -le' > my $str = q/[EMAIL PROTECTED]/; > substr( $str, index $str, q/@/ ) =~ tr/_

Re: quick regex question

2005-03-31 Thread John W. Krahn
Ramprasad A Padmanabhan wrote: Hi, Hello, I want to run a substitution for all instances of "_" with "." after '@' in a string but "_" before "@" should not be touched. eg $str = "[EMAIL PROTECTED]"; Should become [EMAIL PROTECTED] $ perl -le' my $str = q/[EMAIL PROTECTED]/; $str =~ s/([EMAI

quick regex question

2005-03-31 Thread Ramprasad A Padmanabhan
Hi, I want to run a substitution for all instances of "_" with "." after '@' in a string but "_" before "@" should not be touched. eg $str = "[EMAIL PROTECTED]"; Should become [EMAIL PROTECTED] Any suggestions Thanks Ram -- Netco

Re: quick regex question

2001-12-20 Thread Chris Zampese
irst. If it doesn't, then just turn >them into simple variables and use the simple variable instead. > >$field_name = $INPUT{field_name}; > >I'd sure love to see a working example of NET::SMTP, not that you have to, >but >I'm sure I would use it. > >Gary

Re: quick regex question

2001-12-20 Thread Chris Zampese
Tried the double quotes, but then it ignores the $INPUT{field_name} altogether, I think maybe something to do with it being HTML, as I have had it going OK if I just have a simple text message like $mymessage='this is the field $INPUT{field_name}'; --- Chris Zampese <[EMAIL PROTECTED]> wrote: >

Re: quick regex question

2001-12-20 Thread Curtis Poe
--- Chris Zampese <[EMAIL PROTECTED]> wrote: > I have a program that takes input from a form, splits it and saves the values in an >array - > $INPUT{field} > I then create a NET::SMTP mail instance, and message is a string ($mymessage) in >which I have > inserted the form values. > This is so

quick regex question

2001-12-20 Thread Chris Zampese
I have a program that takes input from a form, splits it and saves the values in an array - $INPUT{field} I then create a NET::SMTP mail instance, and message is a string ($mymessage) in which I have inserted the form values. This is so that I can create a form which when submitted will send a

RE: quick regex question

2001-12-12 Thread Curtis Poe
--- Booher Timothy B 1stLt AFRL/MNAC <[EMAIL PROTECTED]> wrote: > Hello and thanks so much for your replies, but don't I need a \! To denote a > literal ! and what about spaces before the bang - don't I want to lose them > too - what about: I don't know. Do you want to lose them? Up to you. Yo

RE: quick regex question

2001-12-12 Thread Booher Timothy B 1stLt AFRL/MNAC
: Booher Timothy B 1stLt AFRL/MNAC; [EMAIL PROTECTED] Subject: Re: quick regex question --- Booher Timothy B 1stLt AFRL/MNAC <[EMAIL PROTECTED]> wrote: > o.k. another regex issue . . . I want a one-liner that can remove everything > after a given character: i.e. > > in

Re: quick regex question

2001-12-12 Thread Curtis Poe
--- Curtis Poe <[EMAIL PROTECTED]> wrote: > with the caveat that any > exclamation points that don't mark quotes are going to cause problems. Ooh. That was coherent. Time for more caffeine. :) = Senior Programmer Onsite! Technology (http://www.onsitetech.com/) "Ovid" on http://www.perlmon

Re: quick regex question

2001-12-12 Thread Curtis Poe
--- Booher Timothy B 1stLt AFRL/MNAC <[EMAIL PROTECTED]> wrote: > o.k. another regex issue . . . I want a one-liner that can remove everything > after a given character: i.e. > > in this case everything after ! (fortran comment): > > would this work: > > perl -npe 's/\!.+$//' > > my thinking i

Re: quick regex question

2001-12-12 Thread Curtis Poe
--- Booher Timothy B 1stLt AFRL/MNAC <[EMAIL PROTECTED]> wrote: > o.k. another regex issue . . . I want a one-liner that can remove everything > after a given character: i.e. > > in this case everything after ! (fortran comment): > > would this work: > > perl -npe 's/\!.+$//' > > my thinking i

RE: quick regex question

2001-12-12 Thread Bob Showalter
> -Original Message- > From: Booher Timothy B 1stLt AFRL/MNAC > [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, December 12, 2001 2:57 PM > To: [EMAIL PROTECTED] > Subject: quick regex question > > > o.k. another regex issue . . . I want a one-liner that can &g

quick regex question

2001-12-12 Thread Booher Timothy B 1stLt AFRL/MNAC
o.k. another regex issue . . . I want a one-liner that can remove everything after a given character: i.e. in this case everything after ! (fortran comment): would this work: perl -npe 's/\!.+$//' my thinking is that \! Is the literal character and . would count for anything + would represent