Re: A Regular Expression Problem in Perl 5.28

2023-03-29 Thread Jim Gibson via beginners
On Mar 28, 2023, at 3:00 PM, Martin McCormick wrote: > > Uri Guttman writes: >> yes, but he kept the {5,} repeat count. so i just kept it too. > > Now that I know how this works, I will probably change to > {4,} as this would match 4 or more digits. From reading the > documentation, {4} means

Re: A Regular Expression Problem in Perl 5.28

2023-03-28 Thread Martin McCormick
Uri Guttman writes: > yes, but he kept the {5,} repeat count. so i just kept it too. Now that I know how this works, I will probably change to {4,} as this would match 4 or more digits. From reading the documentation, {4} means 4 and only 4. {4,6} means 4 but nothing else except 6. {N,}

Re: A Regular Expression Problem in Perl 5.28

2023-03-28 Thread Martin McCormick
Uri Guttman writes: > you also quoted the whole regex in '' but included the // which are the > normal regex delimiters. remove the outer quotes. > and use the qr// form for regexes. > and you don't want the + after the \d as the {5,} is the count. you can't > have both types of repeat counts. > m

Re: A Regular Expression Problem in Perl 5.28

2023-03-28 Thread Sam
On 3/28/23 16:07, Uri Guttman wrote: On 3/28/23 17:01, Martin McCormick wrote: Uri Guttman writes: why are you escaping the {}?? those are meta chars that are needed to make that a 5+ range. just delete the backslashes on them and it will work. First, thank you but read on, please. I

Re: A Regular Expression Problem in Perl 5.28

2023-03-28 Thread Martin McCormick
Uri Guttman writes: > why are you escaping the {}?? those are meta chars that are needed to make > that a 5+ range. just delete the backslashes on them and it will work. First, thank you but read on, please. I couldn't agree more. That should do it but when I don't escape them, I

Re: A Regular Expression Problem in Perl 5.28

2023-03-28 Thread Uri Guttman
On 3/28/23 16:17, Martin McCormick wrote: The string I am interested in testing for starts with 5 or 6 digits in a row and all I need to do is determine that the first 5 or 6 characters are numbers Period. That's all. my $regextest = '/^\d+\{5,\}/' ; why are you escaping the {}?? th

A Regular Expression Problem in Perl 5.28

2023-03-28 Thread Martin McCormick
I've been fighting this for several days and it is a very simple regular expression problem that should be easy enough for a second grader but I can't seem to get it to work. The string I am interested in testing for starts with 5 or 6 digits in a row and all I need to do is

Re: Regular expression problem

2008-11-19 Thread Rob Dixon
Rob Coops wrote: > On Tue, Nov 18, 2008 at 9:52 AM, howa <[EMAIL PROTECTED]> wrote: > >> Hello, >> >> I have two strings: >> >> 1. abc >> 2. abc& >> >> >> The line of string might end with "&" or not, so I use the expression: >> >> (.*)[$&] >> >> Why it didn't work out? > > This does not work bec

Re: Regular expression problem

2008-11-19 Thread howa
Hello On Nov 18, 8:18 pm, [EMAIL PROTECTED] (Rob Coops) wrote: > If you want to capture both lines you end up doing > somehting like this: (.*)&{0,1}$ Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Regular expression problem

2008-11-18 Thread Chas. Owens
On Tue, Nov 18, 2008 at 07:19, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: snip > Inside the [] the meta-character loose their meaning. Only ^ and - have > special meaning. You have to use | instead. snip You missed \, ], and the regex delimiter (default /, but could be nearly anything). Also

Re: Regular expression problem

2008-11-18 Thread John W. Krahn
howa wrote: Hello, Hello, I have two strings: 1. abc 2. abc& The line of string might end with "&" or not, so I use the expression: (.*)[$&] Why it didn't work out? $ perl -le' for ( "abc", "abc&" ) { print; print $1 if /(.*)[$&]/; } ' abc Unmatched [ in regex; marked by <

RE: Regular expression problem

2008-11-18 Thread Stewart Anderson
> -Original Message- > From: Stewart Anderson > Sent: 18 November 2008 12:20 > To: beginners@perl.org > Cc: Stewart Anderson > Subject: RE: Regular expression problem > > > -Original Message- > > From: howa [mailto:[EMAIL PROTECTED] > &

RE: Regular expression problem

2008-11-18 Thread Stewart Anderson
> -Original Message- > From: howa [mailto:[EMAIL PROTECTED] > Sent: 18 November 2008 08:53 > To: beginners@perl.org > Subject: Regular expression problem > > Hello, > > I have two strings: > > 1. abc > 2. abc& > > > The line of string m

Re: Regular expression problem

2008-11-18 Thread Mr. Shawn H. Corey
On Tue, 2008-11-18 at 00:52 -0800, howa wrote: > Hello, > > I have two strings: > > 1. abc > 2. abc& > > > The line of string might end with "&" or not, so I use the expression: > > (.*)[$&] > > > Why it didn't work out? Inside the [] the meta-character loose their meaning. Only ^ and - ha

Re: Regular expression problem

2008-11-18 Thread Rob Coops
On Tue, Nov 18, 2008 at 9:52 AM, howa <[EMAIL PROTECTED]> wrote: > Hello, > > I have two strings: > > 1. abc > 2. abc& > > > The line of string might end with "&" or not, so I use the expression: > > (.*)[$&] > > > Why it didn't work out? > > > Thanks. > > > -- > To unsubscribe, e-mail: [EMAIL PRO

Regular expression problem

2008-11-18 Thread howa
Hello, I have two strings: 1. abc 2. abc& The line of string might end with "&" or not, so I use the expression: (.*)[$&] Why it didn't work out? Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: regular expression problem

2008-08-03 Thread jordilin
On Aug 1, 9:28 am, [EMAIL PROTECTED] wrote: > I'm trying to substitute all comma separated numbers in a text file > with the same numbers without commas.  This expression will match the > numbers: \d{1,3}?(,\d\d\d)+ but how do i refer to each 3 digit block > after the commas so i can substitute for

Re: regular expression problem

2008-08-02 Thread John W. Krahn
John W. Krahn wrote: [EMAIL PROTECTED] wrote: I'm trying to substitute all comma separated numbers in a texv dile with the same numbers without commas. This expression will match the numbers: \d{1,3}?(,\d\d\d)+ but how do i refer to each 3 digit block after the commas so i can substitute for th

Re: regular expression problem

2008-08-02 Thread John W. Krahn
[EMAIL PROTECTED] wrote: I'm trying to substitute all comma separated numbers in a texv dile with the same numbers without commas. This expression will match the numbers: \d{1,3}?(,\d\d\d)+ but how do i refer to each 3 digit block after the commas so i can substitute for them? $1 here just retu

Re: regular expression problem

2008-08-02 Thread Rob Dixon
[EMAIL PROTECTED] wrote: > > I'm trying to substitute all comma separated numbers in a text file > with the same numbers without commas. This expression will match the > numbers: \d{1,3}?(,\d\d\d)+ but how do i refer to each 3 digit block > after the commas so i can substitute for them? $1 here j

Re: regular expression problem

2008-08-02 Thread Rob Coops
Try looking up the 'g' modifier for regular expressions. http://perldoc.perl.org/perlre.html On Fri, Aug 1, 2008 at 10:28 AM, <[EMAIL PROTECTED]> wrote: > I'm trying to substitute all comma separated numbers in a text file > with the same numbers without commas. This expression will match the >

regular expression problem

2008-08-02 Thread seanctaylor1
I'm trying to substitute all comma separated numbers in a text file with the same numbers without commas. This expression will match the numbers: \d{1,3}?(,\d\d\d)+ but how do i refer to each 3 digit block after the commas so i can substitute for them? $1 here just returns the last 3 digit number

Re: filename creating regular expression problem

2007-10-15 Thread Jenda Krynicky
From: "Brad Cahoon" <[EMAIL PROTECTED]> > I keep getting errors saying: > > Use of uninitialized value in concatenation (.) or string at > pagecreate.pl line 25. Apparently one of the variables you use on that line is not initialized. Do you know which one? > print() on closed filehandle FILE a

Re: filename creating regular expression problem

2007-10-15 Thread Brad Cahoon
solved the first problem: while (@ary = $sth->fetchrow_array()){ if ($ary[0] =~ /\//) { @parts = split /\s/, $ary[0]; open FILE, "> c:\/\/output\/$ary[1]\/$parts[0]$ending\n";

filename creating regular expression problem

2007-10-15 Thread Brad Cahoon
HI I keep getting errors saying: Use of uninitialized value in concatenation (.) or string at pagecreate.pl line 25. print() on closed filehandle FILE at pagecreate.pl line 29. i have a script which calls a database and there are values in $ary[0] like: bob smith joe susan / john larry jones /

Re: Regular Expression Problem

2007-08-10 Thread rcook
> > [EMAIL PROTECTED] wrote: >> Mr. Shawn H. Corey wrote: >> > [EMAIL PROTECTED] wrote: >> > > Morning All, >> > > >> > > I've a relatively minor problem that has been giving me a headache >> for >> > > several days. I know there are many other ways to do this, however >> I'd >> > > like to know wh

Re: Regular Expression Problem

2007-08-10 Thread themachinator
[EMAIL PROTECTED] wrote: > Mr. Shawn H. Corey wrote: > > [EMAIL PROTECTED] wrote: > > > Morning All, > > > > > > I've a relatively minor problem that has been giving me a headache for > > > several days. I know there are many other ways to do this, however I'd > > > like to know why this isn't wor

Re: Regular Expression Problem

2007-08-10 Thread themachinator
[EMAIL PROTECTED] wrote: > Mr. Shawn H. Corey wrote: > > [EMAIL PROTECTED] wrote: > > > Morning All, > > > > > > I've a relatively minor problem that has been giving me a headache for > > > several days. I know there are many other ways to do this, however I'd > > > like to know why this isn't wor

Re: Regular Expression Problem

2007-08-10 Thread Paul Lalli
On Aug 10, 8:28 am, [EMAIL PROTECTED] wrote: > I ought clarify. No, you ought to post a short-but-complete script to start with, and not assume you know what one specific line of the program is causing problems. > It's not a problem with the command line, or anything like that, it's > a problem w

Re: Regular Expression Problem

2007-08-10 Thread Paul Lalli
On Aug 10, 9:27 am, [EMAIL PROTECTED] (Oryann9) wrote: > Another hunch looking at your syntax, ideally you > should be using the lesser precedence operator 'and' > instead of the higher precedence operator '&&'. Yes > plz show the command line string. :) > > if($ARGV[2] =~ /port/i and $ARGV[3] =~ /

Re: Regular Expression Problem

2007-08-10 Thread themachinator
Mr. Shawn H. Corey wrote: > [EMAIL PROTECTED] wrote: > > Morning All, > > > > I've a relatively minor problem that has been giving me a headache for > > several days. I know there are many other ways to do this, however I'd > > like to know why this isn't working. The snippet of code in question >

Re: Regular Expression Problem

2007-08-10 Thread oryann9
> > like to know why this isn't working. The snippet > of code in question > > is as follows > > > > > > if($ARGV[2] =~ /port/i && $ARGV[3] =~ /nick/i) > > { > > > > Well, on a hunch I'd say that snippet returns false > because either > $ARGV[2] doesn't match /port/i, or because $ARGV[3] > doe

Re: Regular Expression Problem

2007-08-10 Thread Paul Lalli
On Aug 10, 6:26 am, [EMAIL PROTECTED] wrote: > Morning All, > > I've a relatively minor problem that has been giving me a headache for > several days. I know there are many other ways to do this, however I'd > like to know why this isn't working. The snippet of code in question > is as follows > >

Re: Regular Expression Problem

2007-08-10 Thread Mr. Shawn H. Corey
[EMAIL PROTECTED] wrote: Morning All, I've a relatively minor problem that has been giving me a headache for several days. I know there are many other ways to do this, however I'd like to know why this isn't working. The snippet of code in question is as follows if($ARGV[2] =~ /port/i && $ARGV

Regular Expression Problem

2007-08-10 Thread themachinator
Morning All, I've a relatively minor problem that has been giving me a headache for several days. I know there are many other ways to do this, however I'd like to know why this isn't working. The snippet of code in question is as follows if($ARGV[2] =~ /port/i && $ARGV[3] =~ /nick/i) { Thanks

RE: simple regular expression problem

2004-10-20 Thread Steve Bertrand
> Steve Bertrand wrote: > ... >> while ($buf = ) { >> # $buf now contains line of file, one per each loop of while >> $buf =~ /(\w+)/; >> $userName = $1; >> ...do something with $userName >> } > > This is a common error. You should not use $1 without making sure the > regex > did in

RE: simple regular expression problem

2004-10-20 Thread Bob Showalter
Steve Bertrand wrote: ... > while ($buf = ) { > # $buf now contains line of file, one per each loop of while > $buf =~ /(\w+)/; > $userName = $1; > ...do something with $userName > } This is a common error. You should not use $1 without making sure the regex did in fact match. Othe

RE: simple regular expression problem

2004-10-20 Thread Steve Bertrand
alter [mailto:[EMAIL PROTECTED] > Sent: Tuesday, October 19, 2004 8:57 AM > To: 'Khairul Azmi'; [EMAIL PROTECTED] > Subject: RE: simple regular expression problem > > Khairul Azmi wrote: >> Hi all, >> I am a newbie. I just need to extract the string containing

RE: simple regular expression problem

2004-10-20 Thread Steve Bertrand
'@', returning 'user' (w/o quotes). Read: perldoc perlop perldoc perlretut perldoc perlre I HTH, and I surely hope that I've been reasonably accurate with my assessment. Steve > > Thanks > > AD > > -Original Message----- > From: Bob Showalt

RE: simple regular expression problem

2004-10-20 Thread adisegna
D] Subject: RE: simple regular expression problem Khairul Azmi wrote: > Hi all, > I am a newbie. I just need to extract the string containing the unix > account from the following text > > <[EMAIL PROTECTED]> SIZE=1024. I'm guessing you want to extract the string &q

RE: simple regular expression problem

2004-10-19 Thread Bob Showalter
Khairul Azmi wrote: > Hi all, > I am a newbie. I just need to extract the string containing the unix > account from the following text > > <[EMAIL PROTECTED]> SIZE=1024. I'm guessing you want to extract the string "user"? (But how do you know that that corresponds to a Unix account?) The followi

Re: simple regular expression problem

2004-10-19 Thread Gunnar Hjalmarsson
Khairul Azmi wrote: I just need to extract the string containing the unix account from the following text <[EMAIL PROTECTED]> SIZE=1024. Can anyone tell me how to do it in perl? Try the docs. perldoc perlrequick perldoc perlretut perldoc perlre Thanks in advance. You're welcome. -- Gunn

simple regular expression problem

2004-10-19 Thread Khairul Azmi
Hi all, I am a newbie. I just need to extract the string containing the unix account from the following text <[EMAIL PROTECTED]> SIZE=1024. Can anyone tell me how to do it in perl? Thanks in advance. Azmi -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROT

RE: Regular expression problem.

2003-07-06 Thread Pandey Rajeev-A19514
FastEthernet3/9 lifEntry.20.13 = administratively down * Thanks Rajeev -Original Message- From: Rob Dixon [mailto:[EMAIL PROTECTED] Sent: Saturday, July 05, 2003 8:21 PM To: [EMAIL PROTECTED] Subject: Re: Regular expression problem. Pandey Rajeev-A19514 wrote:

Re: Regular expression problem.

2003-07-05 Thread Jeff 'japhy' Pinyan
On Jul 5, Pandey Rajeev-A19514 said: >*** > ifEntry.1.13 = 13 > ifEntry.2.13 = FastEthernet3/9 > ifEntry.3.13 = 6 > lifEntry.20.13 = administratively down >Jul 5 03:22:33.851 cst: SNMP: Queuing packet to 10.3.0.1 >Jul 5 03:22:33.851 cst

Re: Regular expression problem.

2003-07-05 Thread Rob Dixon
Pandey Rajeev-A19514 wrote: > Hi, > > Can anyone give me a regular expression(perhaps a one liner) ? > Matching an expression in a single line is easy. But if I have to find it out in a > array of scalars, it becomes tricky for me. > > An excerpt of my output buffer looks like this. >

Regular expression problem.

2003-07-05 Thread Pandey Rajeev-A19514
Hi, Can anyone give me a regular expression(perhaps a one liner) ? Matching an expression in a single line is easy. But if I have to find it out in a array of scalars, it becomes tricky for me. An excerpt of my output buffer looks like this. *