regex help?

T

tomo

Can someone please write me regex for which this string will have a
match.Thanks.

12.333,55
12.444.444,55
15.444.444.,55



__________ Information from ESET NOD32 Antivirus, version of virus signature database 4640 (20091126) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 
T

Tim Slattery

tomo said:
Can someone please write me regex for which this string will have a
match.Thanks.

12.333,55
12.444.444,55
15.444.444.,55

/(\d{1,3}.)*,\d{2}/
 
E

Evertjan.

Tim Slattery wrote on 03 dec 2009 in comp.lang.javascript:
/(\d{1,3}.)*,\d{2}/

No, this will not match the first two strings.

/.*/ would do better and simpler.

For specifieing a regex match you would need inclusion as well as exclusion
criteria, which the OP did not provide us with.
 
T

Thomas 'PointedEars' Lahn

tomo said:
Can someone please write me regex for which this string will have a
match.Thanks.

12.333,55
12.444.444,55
15.444.444.,55

man 1 txt2regex


PointedEars
 
T

Tim Slattery

Evertjan. said:
Tim Slattery wrote on 03 dec 2009 in comp.lang.javascript:


No, this will not match the first two strings.

Nuts, you're right! It's going to insist on a period before the comma.
/.*/ would do better and simpler.

But it wouldn't restrict it to digits, nor would it enforce the
groups. We could do:

/(\d{1,3}.?)*,\d{2}/

But that would allow long strings of digits without any punctuation.
 
T

Thomas 'PointedEars' Lahn

Tim said:
Nuts, you're right! It's going to insist on a period before the comma.

Exactly :)
But it wouldn't restrict it to digits, nor would it enforce the
groups.

Given the specifications, it does not need to.
We could do:

/(\d{1,3}.?)*,\d{2}/

But that would allow long strings of digits without any punctuation.

OK, this is probably homework, but I'll bite:

/1[25](\.[34]{3}){1,2}\.?,55/

Hopefully somebody can learn something from that ;-)


PointedEars
 
T

Tim Slattery

Tim Slattery said:
Nuts, you're right! It's going to insist on a period before the comma.

OK, assuming OP wanted to match strings of digits broken into groups
of 3 by dots, optionally followed by a comma then two digits:

(\\d{1,3})(\\.\\d{3})*(\\,\\d{2})?

For US numeric punctuation (12,345.67):

(\\d{1,3})(\\,\\d{3})*(\\.\\d{2})?
 
T

Tim Slattery

Thomas 'PointedEars' Lahn said:
That would only work if it would be passed as content of a string value
to RegExp(). But since there is no variable part in it, RegExp() is
unnecessary, a RegExp initializer /.../ suffices (and you must not escape
the escaping backslash there).

Whether you try to escape the comma remains a mystery, too.

It's a mystery to me too, but it wouldn't work without it.
 
T

Thomas 'PointedEars' Lahn

Tim said:
OK, assuming OP wanted to match strings of digits broken into groups
of 3 by dots, optionally followed by a comma then two digits:

(\\d{1,3})(\\.\\d{3})*(\\,\\d{2})?

For US numeric punctuation (12,345.67):

(\\d{1,3})(\\,\\d{3})*(\\.\\d{2})?

That would only work if it would be passed as content of a string value
to RegExp(). But since there is no variable part in it, RegExp() is
unnecessary, a RegExp initializer /.../ suffices (and you must not escape
the escaping backslash there).

Whether you try to escape the comma remains a mystery, too.

RTFM.


PointedEars
 
E

Evertjan.

Tim Slattery wrote on 04 dec 2009 in comp.lang.javascript:
It's a mystery to me too, but it wouldn't work without it.

The weather will always remain a mystery to,
it's raining cats and dogs,
and my dog needs to go outside NOW.
 

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

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top