Re: regexp question

2009-09-05 Thread John W. Krahn
Noah Garrett Wallach wrote: Okay I am having troubles finding this. in the perldoc modules. Is there a slicker way to write the following? if ($line =~ /(Blah1)(.*)/) { At this point we know that the pattern matched so $1 will contain the string "Blah1" and $2 will contain a string o

Re: regexp question

2009-09-04 Thread Chas. Owens
On Fri, Sep 4, 2009 at 23:06, Noah Garrett Wallach wrote: > > > Okay I am having troubles finding this. in the perldoc modules. > Is there a slicker way to write the following? > >        if ($line =~ /(Blah1)(.*)/) { >             $blah = $1 if $1; >             $blah2 = $2 if $2; >        } snip

regexp question

2009-09-04 Thread Noah Garrett Wallach
Okay I am having troubles finding this. in the perldoc modules. Is there a slicker way to write the following? if ($line =~ /(Blah1)(.*)/) { $blah = $1 if $1; $blah2 = $2 if $2; } -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For ad

Re: regexp question

2009-09-04 Thread Erez Schatz
2009/9/4 Noah Garrett Wallach : > is there any way to search for the following text?  In some cases the text > that I am search could be > > "one-two-three-" > or sometimes the text could be "one-two-" If you're looking for this specific text then a good answer was already given, but if that's an

Re: regexp question

2009-09-04 Thread Chas. Owens
On Fri, Sep 4, 2009 at 04:08, Noah Garrett Wallach wrote: > > Hi there, > > is there any way to search for the following text?  In some cases the text > that I am search could be > > "one-two-three-" > > or sometimes the text could be > > "one-two-" > > what is a nice easy why to parse the above -

regexp question

2009-09-04 Thread Noah Garrett Wallach
Hi there, is there any way to search for the following text? In some cases the text that I am search could be "one-two-three-" or sometimes the text could be "one-two-" what is a nice easy why to parse the above - quotes not included. -- To unsubscribe, e-mail: beginners-unsubscr...@p

Re: Regexp-Question: What is backtracking?

2009-03-12 Thread Erez Schatz
2009/3/12 Deviloper > Can somebody explain what Backtracking is? > > thanx, > B. > In a nutshell, consider the following regex: /foo((b+)ar)/ a regex engine will check every character in the string that is checked against until it reaches the first "f". When reached, it will mark the place and ch

Regexp-Question: What is backtracking?

2009-03-12 Thread Deviloper
This may sound a little bit stupid, but I never ask about "what is up with this regexps behind the curtain". I was lucky when they did what I was expecting... But I´m getting old and want to know more. Can somebody explain what Backtracking is? thanx, B.

Re: another regexp question

2002-10-14 Thread John W. Krahn
Duarte Cordeiro wrote: > > Hi, Hello, > Background: > I have a @filelist that can have (guess what) several filenames. > I want to split the filenames in 3 arrays: > - if the file is in a directory *\templatedata\*\data\ it should go to array1; > - if the file is in a directory \binaries\* i

Re: another regexp question

2002-10-14 Thread Frank Wiles
.--[ Duarte Cordeiro wrote (2002/10/14 at 16:42:35) ]-- | | Hi, | | Background: | I have a @filelist that can have (guess what) several filenames. | I want to split the filenames in 3 arrays: | - if the file is in a directory *\templatedata\*\data\ it should go | t

another regexp question

2002-10-14 Thread Duarte Cordeiro
Hi, Background: I have a @filelist that can have (guess what) several filenames. I want to split the filenames in 3 arrays: - if the file is in a directory *\templatedata\*\data\ it should go to array1; - if the file is in a directory \binaries\* it should go to array2; - any other file shou

simple grep/regexp question

2002-03-26 Thread Brian Warn
This is actually a straight-unix grep question. I want to look for values greater than one in a particular result. What is the recommended, etc. way to do this? -Brian -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Regexp question...

2001-12-22 Thread Andrea Holstein
"John W. Krahn" schrieb: > > Andrea Holstein wrote: > > > > A matching always return a list of the captured items. > > On the left side of the assignment is a scalar, > > so list in a scalar context returns its size. > ^ > While this is true that is _n

Re: Regexp question...

2001-12-21 Thread Michael R. Wolf
"John W. Krahn" <[EMAIL PROTECTED]> writes: > $ perl -le'$data = "one two three four five six"; > $test = $data =~ /(\S+)\s+(\S+)\s+(\S+)/; > print "Test 1: $test"; > ($test) = $data =~ /(\S+)\s+(\S+)\s+(\S+)/; > print "Test 2: $test"; > $test = $data =~ /(\S+)\s+(\S+)\s+(\S+)/g; > print "Test

Re: Regexp question...

2001-12-21 Thread John W. Krahn
Andrea Holstein wrote: > > Wim De Hul wrote: > > > > I tried with: > > > > $_ = &snmpget($sysdescr); > > $IOS_version = /Version (.*?)\, /i; > > > > When I do now: print "$1\n"; I get the IOS version > > But when I type print "$IOS_version\n"; It displays just 1... > > Can I get r

Re: Regexp question...

2001-12-21 Thread John W. Krahn
Wim De Hul wrote: > > Hey folks, Hello, > I'm writen a script to manage my router configuration. > To get the IOS version I use regular expressions. > First, I did it with: > > $_ = &getparameter($sysdescr_mib,"System description");# Get > the SysDescr via SNMP > /Version /

Re: Regexp question...

2001-12-21 Thread Andrea Holstein
Wim De Hul wrote: > > Hey folks, > > I'm writen a script to manage my router configuration. > To get the IOS version I use regular expressions. > First, I did it with: > > $_ = &getparameter($sysdescr_mib,"System description");# Get > the SysDescr via SNMP > /Version /; >

Regexp question...

2001-12-21 Thread Wim De Hul
Hey folks, I'm writen a script to manage my router configuration. To get the IOS version I use regular expressions. First, I did it with: $_ = &getparameter($sysdescr_mib,"System description");# Get the SysDescr via SNMP /Version /; $_ = $'; (/, /); $

Re: YARQ (Yet Another Regexp Question)

2001-11-13 Thread A. Rivera
; Agustin Rivera - Original Message - From: "Etienne Marcotte" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, November 13, 2001 11:44 AM Subject: YARQ (Yet Another Regexp Question) > I saw somewhere on the web a good regexp for removing html tags. Can&#x

Re: YARQ (Yet Another Regexp Question)

2001-11-13 Thread Etienne Marcotte
x27;t know. Anyways I'll fool around a little Etienne Bob Showalter wrote: > > > -Original Message- > > From: Etienne Marcotte [mailto:[EMAIL PROTECTED]] > > Sent: Tuesday, November 13, 2001 2:44 PM > > To: [EMAIL PROTECTED] > > Subject: YARQ (Yet A

Re: YARQ (Yet Another Regexp Question)

2001-11-13 Thread Curtis Poe
--- Etienne Marcotte <[EMAIL PROTECTED]> wrote: > I saw somewhere on the web a good regexp for removing html tags. Can't > re-find it and it needed some minor mods. Etienne, No offense, but there are not good regexes for removing HTML tags. Here are some legal tags that break most regular expr

RE: YARQ (Yet Another Regexp Question)

2001-11-13 Thread Bob Showalter
> -Original Message- > From: Etienne Marcotte [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, November 13, 2001 2:44 PM > To: [EMAIL PROTECTED] > Subject: YARQ (Yet Another Regexp Question) > > > I saw somewhere on the web a good regexp for removing html tags. C

YARQ (Yet Another Regexp Question)

2001-11-13 Thread Etienne Marcotte
I saw somewhere on the web a good regexp for removing html tags. Can't re-find it and it needed some minor mods. Let's say the $line is 'this is a large wordin size 2'; I played a little around, but it always removed between the first < and the last > (and I knwo the tutorial on the web said how

Re: regexp question

2001-11-03 Thread Martin Karlsson
Thanks Jeff! Works like a charm! Be well! /Martin * Jeff 'japhy' Pinyan ([EMAIL PROTECTED]) wrote: > On Nov 3, Martin Karlsson said: > > >Could anyone give me a push in the right direction, please? > >How do I write a regexp that matches double instances of letters (in a > >file i read into a va

Re: regexp question

2001-11-03 Thread Jeff 'japhy' Pinyan
On Nov 3, Martin Karlsson said: >Could anyone give me a push in the right direction, please? >How do I write a regexp that matches double instances of letters (in a >file i read into a variable), e.g. aa LL pp etc. ? > >Is there an easy way, or must I use > (aa|bb|cc|... and so on ) ? You

regexp question

2001-11-03 Thread Martin Karlsson
Hi all! Could anyone give me a push in the right direction, please? How do I write a regexp that matches double instances of letters (in a file i read into a variable), e.g. aa LL pp etc. ? Is there an easy way, or must I use (aa|bb|cc|... and so on ) ? Thanks for your time! --

RE: regexp question

2001-10-23 Thread Richard_Cox
On 23 October 2001 12:21 Jerry Preston [mailto:[EMAIL PROTECTED]] wrote: > I want to break down this name, pgrap.C4A2S1R.1.gif, into 4 parts. I > can do it with split: > > ( $a1,$a2,$a3,$a4 ) = split( /\./, $program ); > > How do I do it with s/\b(\.)\b(\.)\b(\.)\b(\.)/? >

Re: regexp question

2001-10-23 Thread register
my $string = 'pgrap.C4A2S1R.1.gif'; my @s = ($string =~ /(?:\.)*(\w+)(?:\.)*/g); the arraytores the elements the //g makes it find more than one match ... post again if you need more explanation ... hth On Tue, Oct 23, 2001 at 06:20:31AM -0500, Jerry Preston shaped the electrons to read: > Hi,

regexp question

2001-10-23 Thread Jerry Preston
Hi, I want to break down this name, pgrap.C4A2S1R.1.gif, into 4 parts. I can do it with split: ( $a1,$a2,$a3,$a4 ) = split( /\./, $program ); How do I do it with s/\b(\.)\b(\.)\b(\.)\b(\.)/? Thanks, Jerry -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional c

Re: regexp question

2001-10-22 Thread Andrea Holstein
Andrea Holstein wrote: > > ( $a1,$a2,$a3,$a4 ) = $program =~ m/^(.+)\.(.+)\.(.+)\.(.+)$/; > Oh, I see, it's a slow solution. Substitute every (.+) with ([^\.]+) and the pattern matching will be quite quicker. Greetings, Andrea -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional comman

Re: regexp question

2001-10-22 Thread Andrea Holstein
Jerry Preston wrote: > > I want to break down this name, pgrap.C4A2S1R.1.gif, into 4 parts. I > can do it with split: > > ( $a1,$a2,$a3,$a4 ) = split( /\./, $program ); > > How do I do it with s/\b(\.)\b(\.)\b(\.)\b(\.)/? > Don't use substutions when you want to get parts

regexp question

2001-10-22 Thread Jerry Preston
Hi, I want to break down this name, pgrap.C4A2S1R.1.gif, into 4 parts. I can do it with split: ( $a1,$a2,$a3,$a4 ) = split( /\./, $program ); How do I do it with s/\b(\.)\b(\.)\b(\.)\b(\.)/? Thanks, Jerry -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional com

Re: regexp question

2001-10-21 Thread Andrea Holstein
Birgit Kellner wrote: > > my $header = "Joe DoeThe book I wrote yesterday"; > my $title; > if ($header =~ /(^\S.+)()(\S.+$)/m) { $title = "$1: $3";} > print "$title\n"; > > Is there a shorter, simpler, more efficient way to do this? I still need > $header later on as it is. > I try to go anothe

Re: regexp question

2001-10-19 Thread Jeff 'japhy' Pinyan
On Oct 19, birgit kellner said: >> ($title = $header) =~ s//: /; > >I had thought of that, but believed that it will also perform the >substitution on $header. I just tested it, and that doesn't seem to be the >case. If that's true, there's the solution to my problem. Doing ($x = $y) =~ s/fo

Re: regexp question

2001-10-19 Thread birgit kellner
--On Freitag, 19. Oktober 2001 12:49 -0400 Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> wrote: > On Oct 19, birgit kellner said: > >> my $header = "Joe DoeThe book I wrote yesterday"; >> my $title; >> if ($header =~ /(^\S.+)()(\S.+$)/m) { $title = "$1: $3";} >> print "$title\n"; >> >> Is there a shor

Re: regexp question

2001-10-19 Thread Jeff 'japhy' Pinyan
On Oct 19, birgit kellner said: >my $header = "Joe DoeThe book I wrote yesterday"; >my $title; >if ($header =~ /(^\S.+)()(\S.+$)/m) { $title = "$1: $3";} >print "$title\n"; > >Is there a shorter, simpler, more efficient way to do this? I still need >$header later on as it is. You could do: (

Re: regexp question

2001-10-19 Thread Martin
try this: my $title =~ s// /i; if ($header =~ /(^\S.+)()(\S.+$)/m) { $header =~ s///i; } print $header; hope it helps martin birgit kellner wrote: > my $header = "Joe DoeThe book I wrote yesterday"; > my $title; > if ($header =~ /(^\S.+)()(\S.+$)/m) { $title = "$1: $3

regexp question

2001-10-19 Thread birgit kellner
my $header = "Joe DoeThe book I wrote yesterday"; my $title; if ($header =~ /(^\S.+)()(\S.+$)/m) { $title = "$1: $3";} print "$title\n"; Is there a shorter, simpler, more efficient way to do this? I still need $header later on as it is. I quite often have to copy the value of a variable and the

Re: very basic regexp question

2001-09-26 Thread claement claementson
Great stuff. Regexp objects rock. It worked perfectly and helped with some other things too. Thanks a lot Jeff. CC >From: Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> >Reply-To: [EMAIL PROTECTED] >To: claement claementson <[EMAIL PROTECTED]> >CC: [EMAIL PROTECTE

Re: very basic regexp question

2001-09-26 Thread Jeff 'japhy' Pinyan
On Sep 27, claement claementson said: >1. I'm trying to pass a regexp in $bandNameRE through to a while loop, but >it keeps bailing complaining about an "unrecognised escpape \S", but when I >put the regexp directly into the condition it's happy. Why is this? That's because you're using a doub

very basic regexp question

2001-09-26 Thread claement claementson
Hello again, This is so basic I'm embarrassed to ask. Sorry. 1. I'm trying to pass a regexp in $bandNameRE through to a while loop, but it keeps bailing complaining about an "unrecognised escpape \S", but when I put the regexp directly into the condition it's happy. Why is this? 2. The other th

Simple split() Regexp question

2001-06-30 Thread Sanjeeb Basak
Hi, I want to perform a simple split operation, but can't get the regular expr working. Can anybody help me on this? my $line from a file read is: xyz abc 12sd "pqr stz" dfg (delimited by blank char). I'm doing my ($par1, $par2, $par3, $par4, $par5) = split(/ /, $line); and I'm getting $par4 =

Re: Regexp question

2001-06-25 Thread Me
> On Tue, 26 Jun 2001, Tim Wood wrote: > > > Drats - just when I got the regexp worked out too... > > $_=~ m/()/ > > Until you get to the one that is like > > > a bunch of stuff > And of course, when you fix that simple exception, the next slightly more complicated exception comes along.

Re: Regexp question

2001-06-25 Thread Brett W. McCoy
On Tue, 26 Jun 2001, Tim Wood wrote: > Drats - just when I got the regexp worked out too... > $_=~ m/()/ Until you get to the one that is like a bunch of stuff Which is why the parser module is a good idea -- it can handle non-idiomatic cases like this. -- Brett

Re: Regexp question

2001-06-25 Thread Me
> Drats - just when I got the regexp worked out too... > $_=~ m/()/ Kudos for working out the regex that works given your assumptions. If the web pages you will be parsing are known to be constrained to the assumptions you've established, then you're done. But be aware that your regex will fail

Re: Regexp question

2001-06-25 Thread Tim Wood
Drats - just when I got the regexp worked out too... $_=~ m/()/ > > [matching web page links] > > [using regexes] > > Don't use regexes. They aren't the right tools for the task. > > Use one of the cpan modules for parsing web pages. > Some are written specifically for pulling out links. > > htt

Re: Regexp question

2001-06-25 Thread Me
> [matching web page links] > [using regexes] Don't use regexes. They aren't the right tools for the task. Use one of the cpan modules for parsing web pages. Some are written specifically for pulling out links. http://search.cpan.org/

Regexp question

2001-06-25 Thread Tim Wood
Hi I'm new to perl and have a question about regexps that hopefully one of you can help with. I'm trying to parse out links from web pages, so essentially I have a string of the form: So what I want to do is find an expression to match against that. Secondly, if there is an easy way to put

Re: regexp question

2001-06-07 Thread Martin Weinless
Hi, New messages are coming in as I write. Thanks to all. My error was in assuming that because '.' is a metacharacter, the match must start with the initial 's'. However as was pointes out (and in retrospect, it makes perfect sense, the regexp engine is looking for any single character before t

Re: regexp question

2001-06-07 Thread Peter Scott
At 10:10 AM 6/7/01 -0700, Paul wrote: > . matches the r in supernova > n+ matches one or more n's, so it matches the n in supernova > . matches the o in supervova > .? matches one or no characters, so it matches nothing > (successfully, twice) > v* matches any number of v's, includ

Re: regexp question

2001-06-07 Thread Paul
--- Martin Weinless <[EMAIL PROTECTED]> wrote: > take the regexp '.n+..?.?v*.' > > By all that is sacred, if we use the string 'supernova', there should > be no match since there are too many characters before the 'n' Not true. . matches the r in supernova n+ matches one or more n's, so it

Re: regexp question

2001-06-07 Thread Pete Emerson
Martin, Let me take a crack at it, and explain it so that it might help some beginners, too. I wrote this code: $text='supernova'; if ($text=~/.n+..?.?v*./) { print "match.\n"; } which just takes your regular expression and applies it. The if statement is true, I ran it just to make sure.

Re: regexp question

2001-06-07 Thread Michael.Firestone
as you expect. Mik --- Mik Firestone Pinky, are you pondering what I am pondering? Well, I think so Brain, but if we didn't have ears, we would look just like weasels. Martin Weinless <[EMAIL PROTECTED]> 06/07/01 11:25 AM To: <[EMAIL PROTECTED]> cc:

RE: regexp question

2001-06-07 Thread Wagner-David
Since you are not anchoring in way or another(\b or ^ or \W), it meets your criteria of any character then n then Wags ;) -Original Message- From: Martin Weinless [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 07, 2001 08:25 To: [EMAIL PROTECTED] Subject: regexp question Hello

Re: regexp question

2001-06-07 Thread Peter Scott
At 08:25 AM 6/7/2001 -0700, Martin Weinless wrote: >take the regexp '.n+..?.?v*.' > >By all that is sacred, if we use the string 'supernova', there should be >no match since there are too many characters before the 'n' > >However, any regexp checking code will report a match. Atom by atom: . -

Re: regexp question

2001-06-07 Thread Michael Fowler
On Thu, Jun 07, 2001 at 08:25:05AM -0700, Martin Weinless wrote: > take the regexp '.n+..?.?v*.' > > By all that is sacred, if we use the string 'supernova', there should be > no match since there are too many characters before the 'n' Nope. Consider supern ova ^^ ^

Re: regexp question

2001-06-07 Thread Jeff 'japhy' Pinyan
On Jun 7, Martin Weinless said: >take the regexp '.n+..?.?v*.' > >By all that is sacred, if we use the string 'supernova', there should be >no match since there are too many characters before the 'n' > >However, any regexp checking code will report a match. You're not saying "the string must sta

regexp question

2001-06-07 Thread Martin Weinless
Hello, This is probably not a true beginners question - it refers to an example that I use in class when we discuss regexps. Here is the problem: take the regexp '.n+..?.?v*.' By all that is sacred, if we use the string 'supernova', there should be no match since there are too many characters

Re: Regexp Question Again

2001-05-11 Thread Paul
--- "Gross, Stephan" <[EMAIL PROTECTED]> wrote: > I wasn't clear last time. I wrote: > >I want to match the following: > >1) the letters "PT" > >2) a space or nothing > >3) a word that may or may not be in parentheses or even not exist > >and return item #3 (which may be null) > >Example: > >PT

Re: Regexp Question Again

2001-05-11 Thread M.W. Koskamp
- Original Message - From: Gross, Stephan <[EMAIL PROTECTED]> To: 'Beginner Perl' <[EMAIL PROTECTED]> Sent: Friday, May 11, 2001 5:26 PM Subject: Regexp Question Again > I wasn't clear last time. I wrote: > >I want to match the following: >

Re: Regexp Question Again

2001-05-11 Thread Jeff Pinyan
On May 11, Gross, Stephan said: >I wasn't clear last time. I wrote: >>I want to match the following: >>1) the letters "PT" >>2) a space or nothing >>3) a word that may or may not be in parentheses or even not exist >>and return item #3 (which may be null) >>Example: >>PT (XYZ) or PT XYZ or PTXYZ

Regexp Question Again

2001-05-11 Thread Gross, Stephan
I wasn't clear last time. I wrote: >I want to match the following: >1) the letters "PT" >2) a space or nothing >3) a word that may or may not be in parentheses or even not exist >and return item #3 (which may be null) >Example: >PT (XYZ) or PT XYZ or PTXYZ or PT >should return "XYZ" except the la

Re: Regexp Question

2001-05-10 Thread Paul
--- Carl Rogers <[EMAIL PROTECTED]> wrote: > Not having Perl up and running, would this work with the > parenthesis?? > $temp = ~ m/PT[\(]*(\w+)[\)]*/; > $value = $1; > I'm sure there is a one-line answer, but I'm too new to know. > > At 05:13 PM 5/10/2001 -0400, Gross, Stephan wrote: > >I w

RE: Regexp Question

2001-05-10 Thread Nic LAWRENCE
How about this? if (/PT\s*\(?(\w+)\)?/) { $value = $1; } PTMatches the PT \s* Matches any number (or no) spaces \(? Matches one or none ('s (\w+) Matches one or many word characters \)? Matches one or none )'s $1Value caught by (\w+) I think. .. .. maybe. > At 05:13 PM 5/10/20

Re: Regexp Question

2001-05-10 Thread Carl Rogers
Not having Perl up and running, would this work with the parenthesis?? $temp = ~ m/PT[\(]*(\w+)[\)]*/; $value = $1; I'm sure there is a one-line answer, but I'm too new to know. At 05:13 PM 5/10/2001 -0400, Gross, Stephan wrote: >I want to match the following: >1) the letters "PT" >2) a space o

Regexp Question

2001-05-10 Thread Gross, Stephan
I want to match the following: 1) the letters "PT" 2) a space or nothing 3) a word that may or may not be in parentheses or even not exist and return item #3 (which may be null) Example: PT (XYZ) or PT XYZ or PTXYZ or PT should return "XYZ" except the last case, which should return "". I can do