RE: Regex Help

2005-01-27 Thread Dirk Bremer
Sent: Thursday, January 27, 2005 11:50 To: [EMAIL PROTECTED] Cc: Dirk Bremer; perl-win32-users@listserv.ActiveState.com; [EMAIL PROTECTED] Subject: RE: Regex Help The reason that "200412" matches in your first regex is that the first four characters match the pattern (as expected) but ther

RE: Regex Help

2005-01-27 Thread Lloyd Sartor
        To:        <[EMAIL PROTECTED]>,         cc:                 Subject:        RE: Regex Help Dirk, I'm not a regex pro, but this worked for me: /^\d{4}(-\d{2}){0,2}$/ I tested it with this: @test = qw( 2004 200412 20041201 2004-12 2004-12-01 ); foreach $test (@test) {  

RE: Regex Help

2005-01-27 Thread Gardner, Sam
Title: RE: Regex Help Okay, this is amazingly cloddish, but it does work and may point out where some of your regexes are going wrong.  Whenever I have difficulty, I try to simplify it down and then analyze. @strings = qw/ 2004 200412 20041201 2004-12 2004-12-01/; for (@strings){ if

RE: Regex Help

2005-01-27 Thread Mike.Owens
Dirk, I'm not a regex pro, but this worked for me: /^\d{4}(-\d{2}){0,2}$/ I tested it with this: @test = qw( 2004 200412 20041201 2004-12 2004-12-01 ); foreach $test (@test) { print "$test : " . ($test =~ /^\d{4}(-\d{2}){0,2}$/ ? "TRUE" : "FALSE") . "\n"; } Regards, Mike -O

RE: RegEx help

2004-12-14 Thread Charles K. Clarkson
[EMAIL PROTECTED] <> wrote: : I wrote a RegEx to let me know if a line of text has exactly : 36 commas in it (the comma is the separator) and I came up : with this. I don't think it is quite right. I could use a : little pointing in the right direction. Any thoughts? You could use tr/// to co

RE: RegEx help

2004-12-14 Thread Thomas, Mark - BLS CTR
Any thoughts? > > > > > >$lines[0] =~/^(.*?,){36}.*?$/ > > > $lines[0] =~ /^[^,](?:*,[^,]*){36}$/ I like Joe's answer, but if you must use a regex this one works: print scalar(my @commas = $lines[0] =~ /(,)/g); - Mark. ___ Perl-Win32-Users mailing l

Re: RegEx help

2004-12-14 Thread Kester Allen
There's a fun little idiom using tr/// to count the number of occurances of a character in a string: perl -le '$str = "a,b,c,d,e"; $count = ($str =~ tr/,/,/); print "$count"' will output "4", the number of commas in "a,b,c,d,e". --Kester > Jeff Williams wrote, on Tue 12/14/2004 11:23 > :

Re: RegEx help

2004-12-14 Thread Pat Kusbel
at 09:23 AM 12/14/2004, Jeff Williams wrote: I wrote a RegEx to let me know if a line of text has exactly 36 commas in it (the comma is the separator) and I came up with this. I don't think it is quite right. I could use a little pointing in the right direction. Any thoughts? $lines[0] =~/^(.*?,){3

RE: RegEx help

2004-12-14 Thread Joe Discenza
Title: RegEx help Jeff Williams wrote, on Tue 12/14/2004 11:23: I wrote a RegEx to let me know if a line of text has exactly 36 commas init (the comma is the separator) and I came up with this. I don't think itis quite right. I could use a little pointing in the right direction. Anythough

Re: regex help

2004-11-03 Thread Andy_Bach
$Bill wrote: > ... and \1 is deprecated for $1. I believe that should read [thanks Greg!] "...and \1 is deprecated on the right side of s///". On the left side (as in any regexp), \1 and $1 differ. But as a holdover from sed, \1 means the same as $1 on the right side of the subst. \1 isn't the

Re: regex help

2004-11-02 Thread $Bill Luebkert
Ganesh Babu Nallamothu, Integra-India wrote: > Hi, > > Your Find patter is wrong. > Use the following Pattern: > > s/([\t]\d{2}[:]\d{2}[\s])/\1/; \t, \s and : do not need to be in a character class and \1 is deprecated for $1. This should be equivalent: s/(\t\d{2}:\d{2}\s)/$1/; You s

RE: regex help

2004-11-02 Thread Ganesh Babu Nallamothu, Integra-India
Hi, Your Find patter is wrong. Use the following Pattern: s/([\t]\d{2}[:]\d{2}[\s])/\1/; Regards, Gopal.R -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Malcolm Mill Sent: Wednesday, November 03, 2004 2:41 AM To: [EMAIL PROTECTED] Subject: regex help Ne

RE: regex help

2004-11-02 Thread Peter Eisengrein
Title: RE: regex help Assuming your dates are always in the same format, this would work: print "$1\n" while ($_ =~ /(\d{1,2}\:\d{2} [ap]m)/gi); -Pete > -Original Message- > From: Malcolm Mill [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, November 02, 2004 4

Re: REGEX help!

2004-01-14 Thread $Bill Luebkert
Jamie Murray wrote: > Hi Glenn, > I have worked on this further and looked at some of the previous posts. > I have tried this with all different combinations of ip address and this has > worked. > Of course I got the idea from a previous post from Alex and Mark Thomas. > Please understand I could

Re: REGEX help!

2004-01-13 Thread Mike Jackson
ced clarity. Happy learning. - Original Message - From: "Glenn Linderman" <[EMAIL PROTECTED]> To: "Jamie Murray" <[EMAIL PROTECTED]> Cc: "$Bill Luebkert" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Tuesday, January 13, 2004 6:24 PM Subjec

Re: REGEX help!

2004-01-13 Thread Jamie Murray
Thanks for the discussion,clear explanation and advice Glenn. - Original Message - From: "Glenn Linderman" <[EMAIL PROTECTED]> To: "Jamie Murray" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, January 14, 2004 12:48 AM Subject: Re:

Re: REGEX help!

2004-01-13 Thread Glenn Linderman
t removes the complex redundancy, and can be expressed in half the lines even with the enhanced clarity. Happy learning. - Original Message - From: "Glenn Linderman" <[EMAIL PROTECTED]> To: "Jamie Murray" <[EMAIL PROTECTED]> Cc: "$Bill Luebkert" &

Re: REGEX help!

2004-01-13 Thread Jamie Murray
.$octet\.$octet\.$octet$/o; print "yes" if $ip =~ $valid_ip; - Original Message - From: "Glenn Linderman" <[EMAIL PROTECTED]> To: "Jamie Murray" <[EMAIL PROTECTED]> Cc: "$Bill Luebkert" <[EMAIL PROTECTED]>; <[EMAIL PROTECT

Re: REGEX help!

2004-01-13 Thread Glenn Linderman
; <[EMAIL PROTECTED]> Sent: Tuesday, January 13, 2004 9:40 AM Subject: Re: REGEX help! BiLL, If you check my second post I made the correction but I'm still correct in my example and method. Actually the e-mail from Raul Davletshin pretty much verifys what I had also stated and he&#x

Re: REGEX help!

2004-01-13 Thread Jamie Murray
correct" I'm all for learning and am just trying my best. Thanks! - Original Message - From: "$Bill Luebkert" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, January 13, 2004 5:07 AM Subject: Re: REGEX help! > Jamie Murray wrote: > >

Re: REGEX help!

2004-01-13 Thread $Bill Luebkert
Jamie Murray wrote: > Hey Alex, > I jumped a little quick there, the previous post does work but I had a doh > moment and forgot your upper range match could only be 254 at most. > Sorry about that. > > if($num =~ > /^[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]$/) ^^^

Re: REGEX help!

2004-01-13 Thread Glenn Linderman
On approximately 1/12/2004 8:36 PM, came the following characters from the keyboard of Jamie Murray: Hey Alex, I jumped a little quick there, the previous post does work but I had a doh moment and forgot your upper range match could only be 254 at most. Sorry about that. if($num =~ /^[0-2][0-5][0-4

Re: REGEX help!

2004-01-13 Thread Raul Davletshin
f ($ip =~ /^\d[0-254]\.\d[0-254]\.\d[0-254]\.\d[0-254]$/) incorect way of matching ip address, it will work fore "61.14.95.02", but will not work for "66.18.99.07". The problem here you just trying to match 2 digital number instead of 3 digits. For example using "[]" [aDc] true for "a" but not f

Re: REGEX help!

2004-01-13 Thread Jamie Murray
Hey Alex, I jumped a little quick there, the previous post does work but I had a doh moment and forgot your upper range match could only be 254 at most. Sorry about that. if($num =~ /^[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]\.[0-2][0-5][0-4]$/) after each class [] use {num,num} to adjust

Re: REGEX help!

2004-01-12 Thread $Bill Luebkert
alex p wrote: > Hello all, > I have been trying to find a regex to validate IP ranges and found the > following: > > m{ >^ ( \d | [01]?\d\d | 2[0-4]\d | 25[0-5] ) > \. ( \d | [01]?\d\d | 2[0-4]\d | 25[0-5] ) > \. ( \d | [01]?\d\d | 2[0-4]\d | 25[0-5] ) > \. ( \d | [0

Re: REGEX help!

2004-01-12 Thread Jamie Murray
just a stab starts with any digit(s) = any number of digits or = 0 or 1 or none(?=can be none but at most 1) followed by any 2 numbers = 2 followed by number between 0 and 4 followed by any number = 25 followed by any number between 0 and 5 followed by "." the rest is repeat (I think that cookbo

RE: Regex Help Needed

2003-09-02 Thread Schneider, Kenneth (EKT)
how about sorting the letters first:   $var="meqgvn";   $sortedvar=join("", sort(split("", $var)));   if ($sortedvar eq "egmnqv") {  print "yes!\n";} --ken -Original Message-From: Dax T. Games [mailto:[EMAIL PROTECTED]Sent: Tuesday, September 02, 2003 12:26 PMTo: Perl UsersS

Re: Regex Help Needed

2003-09-02 Thread $Bill Luebkert
$Bill Luebkert wrote: > Dax T. Games wrote: > > >>I have a list of characters. I need to get a list of all possble >>sequences of these characters for example. >> >>I have a string that consists of '-mevqgn' I need to pattern match any >>combination of 'mevqgn' with a preceding - or --. >> >

Re: Regex Help Needed

2003-09-02 Thread John Deighan
At 01:26 PM 9/2/2003, Dax T. Games wrote: I have a list of characters.  I need to get a list of all possble sequences of these characters for example.    I have a string that consists of '-mevqgn' I need to pattern match any combination of 'mevqgn' with a preceding - or --.   Right now this is w

RE: Regex Help Needed

2003-09-02 Thread Messenger, Mark
Equally dirty, but possibly more flexible:   $_='aSdFgHjk';    # Letters to look for. $alpha1=lc(join('',sort(split(//;   $LS_Val=shift; $LS_Val=~s/^-//g;   # Drop preceding dashes   $alpha2=lc(join('',sort(split(//,$LS_Val;   if ($alpha1 eq $alpha2) {print "Pattern found!\n";}      

RE: Regex Help Needed

2003-09-02 Thread Arms, Mike
It looks like you may be doing standard command line option parsing (or almost standard as the '--' prefix is reserved for long option names). If this is so, look at GetOpt::Std . For a subroutine that does what you specified (tested): sub is_DTG_Option ($) { my $opt = shift; return 0

Re: Regex Help Needed

2003-09-02 Thread Charlie Schloemer
Wow... looks like some good replies to this one. Here's a less elegant, recursive approach (until I learn map :-) #!perl -w # print all 720 permutations using letters: e m v q g n use strict; sub mutate { my ($in) = @_; if (length($in) == 6) { print "$in\n"; $in = ''; } else {

Re: Regex Help Needed

2003-09-02 Thread Carl Jolley
On Tue, 2 Sep 2003, Dax T. Games wrote: > I have a list of characters. I need to get a list of all possble sequences of these > characters for example. > > I have a string that consists of '-mevqgn' I need to pattern match any combination > of 'mevqgn' with a preceding - or --. > > Right now th

RE: Regex Help Needed

2003-09-02 Thread Hanson, Rob
Here is another variation...   #!/usr/bin/perl   check('-mevqgn');check('-memqgn');check('-ngmevq');check('--meqvgn');   sub check{    my $LS_Val = shift;       if ($LS_Val =~ /-{1,2}([mevqgn]{6})/ and unique_chars($1)) {    print "Ding Ding! $LS_Val is good!\n";    }    else {    pr

Re: Regex Help Needed

2003-09-02 Thread Will of Thornhenge
Have you tried playing around with character sets? Something like $target = 'mevqgn'; $length_target = length $target; if ( $LS_Val =~ /-{1,2}[$target]{$length_target}/ ) { #do something } Whether the above would work for you would depend on whether the code can ignore positive matches on $LS_

RE: Regex Help Needed

2003-09-02 Thread Wagner, David --- Senior Programmer Analyst --- WGO
    I wanted to use tr but was uanble to accomplish the task that way. So I used regex like the following:   use strict;   my %MCTWW = qw(m -1 e -1 v -1 q -1 g -1 n -1);my $MyCharsToWorkWith = \%MCTWW;   $_ = '--mepqgn ';   if ( ! /-{1,2}(\S+)/ ) {    printf "Expecting a hyphen or two floowed

Re: Regex Help Needed

2003-09-02 Thread $Bill Luebkert
Dax T. Games wrote: > I have a list of characters. I need to get a list of all possble > sequences of these characters for example. > > I have a string that consists of '-mevqgn' I need to pattern match any > combination of 'mevqgn' with a preceding - or --. > > Right now this is what I am d

RE: Regex help

2003-02-18 Thread Beckett Richard-qswi266
> I'm trying to match a string which would start with http://, > then a character string where there is one one or more > instances of "%", followed by one instance of ".com", i.e. > http://www.%55.com > > Here is my current pattern: > http://.*%+.*(\.com) > > However, if there are tw

Re: RegEx help

2002-11-15 Thread $Bill Luebkert
Bullock, Howard A. wrote: You could cheat a little instead of trying to do it with just a RE, use an embeded tr/// or s///: my $text = 'axxxccvvvacasdcxaswrefajjawerasdcxaswrefajhhaasera'; $text =~ s#(.*?)# my $x = $1; $x =~ tr/a/8/; sprintf '%s', $x #eg; Your two little dashes make my client

RE: RegEx help

2002-11-15 Thread Bullock, Howard A.
You could cheat a little instead of trying to do it with just a RE, use an embeded tr/// or s///: my $text = 'axxxccvvvacasdcxaswrefajjawerasdcxaswrefajhhaasera'; $text =~ s#(.*?)# my $x = $1; $x =~ tr/a/8/; sprintf '%s', $x #eg; -- Thanks. The main problem I was having was I couldn't find th

Re: RegEx help

2002-11-14 Thread $Bill Luebkert
Bullock, Howard A. wrote: I want to alter some characters in a text variable, but only those between two markers. $text = 'axxxccvvvacasdcxaswrefajjawerasdcxaswrefajhhaasera'; I want to specify the start and the end and only change the a's to 8's between the markers. How do I accomplish this

Re: Regex help - trim doc contents

2002-02-04 Thread Jean-Baptiste Nivoit
* Stephen Patterson ([EMAIL PROTECTED]) wrote: > I have a scalar, $doc, which contains a plain ascii file, and which > I'll be storing on a database (for searching). > (...) > > Can anyone help? There's a module called Whitespace on CPAN, would that work for you? Additionnally, there's also a S

Re: Regex help - trim doc contents

2002-01-30 Thread $Bill Luebkert
Joseph P. Discenza wrote: > Stephen Patterson wrote, on > : To minimise the space needed to store this file, I'd like to remove > : all non-word characters and punctuation (except whitespace), and > : replace multiple whitespaces with single whitespaces. > : > : For efficiency, I'd like to do it

RE: Regex Help Please!

2002-01-10 Thread Wagner-David
Nice. Really! Wags ;) -Original Message- From: dolljunkie [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 10, 2002 11:09 To: [EMAIL PROTECTED] Subject: Re: Regex Help Please! A less elegant (perhaps) solution, but effective, no matter how many rows / values: while

Re: Regex Help Please!

2002-01-10 Thread dolljunkie
A less elegant (perhaps) solution, but effective, no matter how many rows / values: while(<>) { s/\r//g; # I hate that carriage return chomp; next if(!/^.*<\!--/); # skip non-matching lines my @values; my $ts = $1 if(s/<\!--\s*(.*?)\s*-->//); my($ts1,$ts2) = split(/\s*

RE: Regex Help Please!

2002-01-10 Thread Brown, Aaron D
:: -Original Message- :: From: Gordon Brandt [mailto:[EMAIL PROTECTED]] :: Sent: Thursday, January 10, 2002 12:17 PM :: To: [EMAIL PROTECTED] :: Subject: Regex Help Please! :: :: [-snip-] :: :: Input file: :: | :: :: (misc header information I want to delete) :: :: #Thi

RE: Regex Help Please!

2002-01-10 Thread Wagner-David
7;; [EMAIL PROTECTED] Subject: RE: Regex Help Please! Works but not if you have more or fewer than 2 values in a row. Do you? > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]]On Behalf Of > Wagner-David > Sent: Thursday, January 10, 2002 1:31 PM >

RE: Regex Help Please!

2002-01-10 Thread Ron Hartikka
Works but not if you have more or fewer than 2 values in a row. Do you? > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]]On Behalf Of > Wagner-David > Sent: Thursday, January 10, 2002 1:31 PM > To: 'Gordon Brandt'; [EMAIL PROTECTE

RE: Regex Help Please!

2002-01-10 Thread Wagner-David
Here is a simplistic approach. May want more edits, but is a starting place. Placing the data for testing under DATA: while ( ) { chomp; next if ( /^\s*$/ ); # bypass blank lines if ( /^ (.+) <\/v> (.+) <\/v><\/row>/ ) { printf "%-s, %-s, %-s, %-s\n", $1, $2, $

Re: Regex Help

2001-03-29 Thread Carl Jolley
"perl-win32-users" <[EMAIL PROTECTED]> > Sent: Tuesday, March 27, 2001 4:05 PM > Subject: Re: Regex Help > > > > > > > > Try using this: > > > > use File::Basename; # fo

Re: Regex Help

2001-03-28 Thread Cameron Dorey
Dirk Bremer wrote: > > I want to build a regular expression that will separate a filename string into the >root name, filename, and extension name, placing > the results in $1, $2, $3. [remainder snipped] Why not just use File::Basename? It does just what you want, if I read your question corr

Re: Regex Help

2001-03-28 Thread Lee Goddard
;[EMAIL PROTECTED]> >To: "Dirk Bremer" <[EMAIL PROTECTED]> >Cc: "perl-win32-users" <[EMAIL PROTECTED]> >Sent: Tuesday, March 27, 2001 4:05 PM >Subject: Re: Regex Help > > > > > > > > Try using this: > >

RE: Regex Help

2001-01-31 Thread Wagner-David
I tried this and it seemed to work: my $InputLine = '(! SUBSTR(DB.USER1,2,5)="9") .AND. (LEFT(DB.USER1,1)<"1") .AND. (ALLTRIM(DB.OUNCEWT)>"2")'; my $InputLine1 = '(! SUjSTR(DB.USER1,2,5)="9") .AND. (LEFT(DB.USER1,1)<"1") .AND. (ALLTRIM(DB.OUNCEWT)>"2")'; my $Str = '(! SUBSTR(DB.USER1,2,5)

Re: Regex: help with '\'

2001-01-14 Thread $Bill Luebkert
"Bullock, Howard A." wrote: > > Is there a way to get the following text to match? If the '\' in '1\V' is > changed, the regex matches. I would like to maintain the RAW text if > possible. > > $c = 'JUA_APPS01\VOL1:\APPS'; > $d = 'JUA_APPS01\VOL'; > if ($c =~ /$d/) > { > print "matched\n