[Tutor] regular expressions

Alan G alan.gauld at freenet.co.uk
Mon Jul 18 10:04:49 CEST 2005


> Using regular expressions how do I represent Floats.

I'm not certain what you mean by that. Regex searches strings,
so the only way floats would be recognised is if you had the
string representation of them. Regex won't work with raw floating
point data.

Assuming you do mean floating point numbers as strings then it depends
again on the representation used in the string.

NNNN.MMMM
.MMMePPPP

etc

You have to look at the string pattern you are interested in
and write a regex to match. The first form is the more common
and searcging for a sequence of numbers followed by a literal
period followed by another sequence of numbers is what you
need. But then you might consider plus/minus signs in front etc.

Can you show us what you tried?

Alan G. 



More information about the Tutor mailing list