www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Example on dlang.org // Round floating point numbers

reply Martin Tschierschke <mt smartdolphin.de> writes:
The example
// Round floating point numbers

with the floating point substitution using the Regex:

  reFloatingPoint = ctRegex!`[0-9]+\.[0-9]+`;

Is not so nice, because it would match for dates like 16.06.2016, 
too.

(I remember having a simmilar problem when trying to substitute 
123.44 Euro to
German format: 123,44 Euro ending up with a modified date: 
16,06.2016)

Sure this may be not the point of the example, but I dislike it 
therefore.

How to expand the Regex not to match dates?

Regards
martin
Jun 16 2016
parent Dmitry Olshansky <dmitry.olsh gmail.com> writes:
On 16-Jun-2016 14:55, Martin Tschierschke wrote:
 The example
 // Round floating point numbers

 with the floating point substitution using the Regex:

  reFloatingPoint = ctRegex!`[0-9]+\.[0-9]+`;
To something like `[0-9]+\.[0-9]+(?![^.])`
 Is not so nice, because it would match for dates like 16.06.2016, too.

 (I remember having a simmilar problem when trying to substitute 123.44
 Euro to
 German format: 123,44 Euro ending up with a modified date: 16,06.2016)

 Sure this may be not the point of the example, but I dislike it therefore.

 How to expand the Regex not to match dates?

 Regards
 martin
-- Dmitry Olshansky
Jun 16 2016