>This should do the trick...
>$List =~ /^(?:([\d|\.]+)\*)?(\w+)\/(?:([\d|\.]+)\*)?(\w+)$/;
Note that this will also pass '12|34.56' as a valid number because
of the '|' in the '[...]'. I think you will really want just '[\d\.]'.
---Larry
+
hi there - I did not try this, but it seems somewhat logical to me:
$List =~ /^(?:(\d+(\.\d+)?)\*)?(\w+)\/(?:(\d+(\.\d+)?)\*)?(\w+)$/;
> > Hello,
> >
> > I have this regular expression:
> >
> > $List =~ /^(?:(\d+)\*)?(\w+)\/(?:(\d+)\*)?(\w+)$/;
> >
> > It checks for a string like this: number
Hi Wagner,
This should do the trick...
$List =~ /^(?:([\d|\.]+)\*)?(\w+)\/(?:([\d|\.]+)\*)?(\w+)$/;
Basically looks like you need a character class to accept a '.' as well.
(However, this reg exp looks like it will let thru 100.0.0.1 is a
number!)
Joel
-Original Message-
From: Wagn
Octavian Rasnita wrote at Sat, 07 Sep 2002 11:03:39 +0200:
> I am trying to match a word boundry or an end of string.
> I would like something like:
>
> /$word[\bX]/
>
> where X is the symbol used for end of string. I know that I can use $ but I
> don't think I can use it between brackets.
>
>
Gsulinux wrote at Sat, 27 Jul 2002 13:32:27 +0200:
> I wanna check the information typed in the form field whether if it is in date
>format or not .
> Like : check it if it is in format day/mount/year , in format like ab/cd/ef or
>ab/cd/efgh "ab"
> must be valid like between 1-31
> "cd" must be
On Saturday, July 27, 2002, at 05:31 , fliptop wrote:
> GsuLinuX wrote:
> >
> > I wanna check the information typed in the form field whether if it
> > is in date format or not .
[..]
> you should look into using Date::Calc. it has many functions for
> checking a date's validity, extracting pa
On a side note, where you said "A[12]" just to avoid future problems
either you wanted A[11] or don't forget to add a blank starting element
in the array, as arrays are indexed starting at 0!!
http://danconia.org
fliptop wrote:
> GsuLinuX wrote:
> >
> > I wanna check the information typed i
GsuLinuX wrote:
>
> I wanna check the information typed in the form field whether if it
> is in date format or not . Like : check it if it is in format
> day/mount/year , in format like ab/cd/ef or ab/cd/efgh "ab" must
> be valid like between 1-31 "cd" must be valid between 1-12 or must
> b
On Monday, May 20, 2002, at 03:43 , Shawn wrote:
> To get just the Auth...
>
> (my $var2=$var)=~s/^.*Proxy-Authorization: Basic //ms;
> $var2=~s/\n.*$//ms;
>
> This is unetested...
actually i just tested it - works well.
> Shawn
>
>> my $var = m/Proxy-Authorization:.+/; #should return true
>>
>
Hey ChaoZ,
> my $var="
> GET http://us.a1.yimg.com/us.yimg.com/i/mntl/lnch/britney.jpg HTTP/1.0
> Host: us.a1.yimg.com
> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.4) Gecko/20011126
> Netscape6/6.2.1
> Accept: text/xml, application/xml, application/xhtml+xml, text/html;q=0.9,
>
On Sunday, May 19, 2002, at 02:30 , Ross Esposito wrote:
> I "think" split is compiled only once while regex (as used in the previous
> posts) is compiled everytime a new line is to be matched. (you can use qr/
> /)
>
> Someone fire up Benchmark. I could be wrong :)
>
> xgunnerx
funny you shoul
nt: Friday, May 17, 2002 10:31 AM
To: Brian; [EMAIL PROTECTED]
Subject: RE: regular expression vs split
I don't believe that a regex would be faster in an instance like this, but
someone please correct me if I'm wrong. It seems that it would add (albeit a
very minimal amount) processing
I just happened to write exactly this the other day,
as a generic configuration file reader. Here's the
basics:
sub readINI {# argument: filename
my %params;
open( INIFILE, $_[0] )
|| die "Could not open $_[0]\n";
while() {
if(! /^#/ ) { # Allow comments
chomp;
t Robnett
inSite Internet Solutions
[EMAIL PROTECTED]
[EMAIL PROTECTED]
-Original Message-
From: Brian [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 17, 2002 10:17 AM
To: [EMAIL PROTECTED]
Subject: RE: regular expression vs split
Curious, but I've always thought that regex was much qui
...it certainly looks like a regex to me
-Original Message-
From: Shawn [mailto:[EMAIL PROTECTED]]
Sent: 17 May 2002 16:03
To: Scot Robnett; ChaoZ Inferno; [EMAIL PROTECTED]
Subject: Re: regular expression
Ok, first, thanks for the correction and input David... I agree 100% with
what
> Actually, the content of the file looks something like:-
> name=john
> id=12345
> password=12345
> colour=blue
Ok, how about this then...
This is based on the fact that name, id, password, colour appear for every record
whether they have a value or not, and that none of the values after the '
;Your $field is $value. \n";
>}
>
>
>Scot Robnett
>inSite Internet Solutions
>[EMAIL PROTECTED]
>[EMAIL PROTECTED]
>
>
>-Original Message-
>From: ChaoZ Inferno [mailto:[EMAIL PROTECTED]]
>Sent: Friday, May 17, 2002 11:38 AM
>To: [EMAIL PROTECTED]
>Su
OTECTED]
>
>
> -Original Message-
> From: ChaoZ Inferno [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 17, 2002 11:38 AM
> To: [EMAIL PROTECTED]
> Subject: Re: regular expression
>
>
> Actually, the content of the file looks something like:-
> name=john
&g
int "Your $field is $value. \n";
}
Scot Robnett
inSite Internet Solutions
[EMAIL PROTECTED]
[EMAIL PROTECTED]
-Original Message-
From: ChaoZ Inferno [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 17, 2002 11:38 AM
To: [EMAIL PROTECTED]
Subject: Re: regular expression
Actually,
quot;David Gray" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: "'ChaoZ InferNo'" <[EMAIL PROTECTED]>; "'Shawn'" <[EMAIL PROTECTED]>
Sent: Friday, May 17, 2002 10:16 PM
Subject: RE: regular expression
> >
> ...
> > f
ChaoZ InferNo wrote:
> @text # contains values of a phone directory
> $text[0] contains john=012345678
>
> $phone1 = ?
>
> let say i wanted to grab just the values'012345678'.
if the format of $text[0] is always name=number you can use split
instead of a regex.
perldoc -f split
--
To uns
>
> for(@text) {
> /(d+)$/; # Match only the numbers at the end of the string
^^
this should actually be (\d+)
I would actually conditionally print also, like so:
print $1 if /(\d+)$/;
And depending on the size of the file, instead of reading the whole
thing into memory wi
Hey Chaoz,
#!/usr/bin/perl
use strict;
open(FILE,');
close(FILE);
for(@text) {
/(d+)$/; # Match only the numbers at the end of the string
# and store them in '$1' to be printed out on the
# next line followed by a new line character
print $1,"\n";
}
exit;
shawn
-
23 matches
Mail list logo