perl regular expression question.

J

Jesper

Hi
I have a string that contains 5<= characters; two (or more) of these
charaters must be numbers - is there anyway to check this with reg. exp. ?

regards,
Jesper
 
K

ko

Jesper said:
Hi
I have a string that contains 5<= characters; two (or more) of these
charaters must be numbers - is there anyway to check this with reg. exp. ?

regards,
Jesper

Here are two options:

print if ( (my $tmp = () = /(\d)/g) >= 2 );
print if tr/0-9// >= 2;

The details are in a FAQ. Just type 'perldoc -q count' from your shell.

HTH - keith
 
J

Jesper

Here are two options:

print if ( (my $tmp = () = /(\d)/g) >= 2 );
print if tr/0-9// >= 2;
nice,

The details are in a FAQ. Just type 'perldoc -q count' from your shell.

That's just was I was looking for - thanks.

Regards,
Jesper
 
T

Tad McClellan

[ attribution missing, please don't do that ]
That's just was I was looking for - thanks.


That is, you know, why FAQs exist in the first place don't you?


You could have saved the world boatloads of time if you'd looked
there _before_ asking thousands of people around the world to
go over it yet again.

Which is why netiquette suggests that you check applicable
FAQs before making a post...
 
J

Jürgen Exner

Tad said:
[ attribution missing, please don't do that ]
That's just was I was looking for - thanks.

That is, you know, why FAQs exist in the first place don't you?

You could have saved the world boatloads of time if you'd looked
there _before_ asking thousands of people around the world to
go over it yet again.

Which is why netiquette suggests that you check applicable
FAQs before making a post...

Tad, come on, give that guy a break.
The Perl FAQ is quite large and it is not easy to find an answer if you
don't know what term to search for.

Quite often all that someone needs (like Jesper) is a little hint as to
_where_ to look for the answer.
He even thanked for the pointer, bashing those people is not nice.

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,247
Latest member
crypto tax software1

Latest Threads

Top