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 of

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:

Re: regexp question

2009-09-04 Thread Chas. Owens
On Fri, Sep 4, 2009 at 04:08, Noah Garrett Wallachnoah-l...@enabled.com 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

Re: regexp question

2009-09-04 Thread Erez Schatz
2009/9/4 Noah Garrett Wallach noah-l...@enabled.com: 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

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

Re: regexp question

2009-09-04 Thread Chas. Owens
On Fri, Sep 4, 2009 at 23:06, Noah Garrett Wallachnoah-l...@enabled.com 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;  

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: Regexp-Question: What is backtracking?

2009-03-12 Thread Erez Schatz
2009/3/12 Deviloper devilo...@slived.net 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

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

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 |

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]

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: 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 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 rid of the S_? A

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 3: $test;

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 font size=2large word/fontin size 2'; I played a little around, but it always removed between the first and the last (and I knwo the tutorial on

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. Can't re-find it and it needed some

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

Re: YARQ (Yet Another Regexp Question)

2001-11-13 Thread Etienne Marcotte
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 Another Regexp Question) I saw somewhere on the web a good regexp

Re: YARQ (Yet Another Regexp Question)

2001-11-13 Thread A. 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't re-find it and it needed some minor mods. Let's say

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-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 want

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

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,

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(\.)/? You

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

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. It's

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

Re: regexp question

2001-10-21 Thread Andrea Holstein
Birgit Kellner wrote: my $header = Joe DoebrbrThe book I wrote yesterday; my $title; if ($header =~ /(^\S.+)(brbr)(\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 another way

regexp question

2001-10-19 Thread birgit kellner
my $header = Joe DoebrbrThe book I wrote yesterday; my $title; if ($header =~ /(^\S.+)(brbr)(\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

Re: regexp question

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

Re: regexp question

2001-10-19 Thread Jeff 'japhy' Pinyan
On Oct 19, birgit kellner said: my $header = Joe DoebrbrThe book I wrote yesterday; my $title; if ($header =~ /(^\S.+)(brbr)(\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 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 DoebrbrThe book I wrote yesterday; my $title; if ($header =~ /(^\S.+)(brbr)(\S.+$)/m) { $title = $1: $3;} print $title\n; Is there a shorter, simpler,

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

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

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 PROTECTED] Subject: Re: very basic regexp question

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 =

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: A href= /A So what I want to do is find an expression to match against that.

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/

Re: Regexp question

2001-06-25 Thread Tim Wood
Drats - just when I got the regexp worked out too... $_=~ m/(A)(.*?)( \/A)/ [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.

Re: Regexp question

2001-06-25 Thread Me
Drats - just when I got the regexp worked out too... $_=~ m/(A)(.*?)( \/A)/ 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

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/(A)(.*?)( \/A)/ Until you get to the one that is like a href=some/url a bunch of stuff /a Which is why the parser module is a good idea -- it can handle non-idiomatic cases like this. --

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

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 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: . - match

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 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: 1) the letters PT 2) a space or nothing 3) a word

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 (XYZ) or PT XYZ or

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