Regular Expressions: Difference between revisions

From David's Wiki
No edit summary
No edit summary
Line 16: Line 16:
Capturing significand and exponent separately.
Capturing significand and exponent separately.
<syntaxhighlight lang="ragel">
<syntaxhighlight lang="ragel">
([-+]?\d*\.?\d+)(?:[eE]([-+]?\d+))
([-+]?\d*\.?\d+)(?:[eE]([-+]?\d+))?
</syntaxhighlight>
</syntaxhighlight>
Capturing the entire string together.
Capturing the entire string together.
<syntaxhighlight lang="ragel">
<syntaxhighlight lang="ragel">
([-+]?\d*\.?\d+[eE][-+]?\d+)
([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)
</syntaxhighlight>
</syntaxhighlight>

Revision as of 12:17, 23 September 2019

Regular expressions are used for matching text.
You can test regular expressions online at [1].


Useful Regular Expressions

Mostly copied from Regex DB.

Floating Point Number

Without matching scientific notation (e.g. 1.5e-6). Reference

[-+]?[0-9]*\.?[0-9]+

With matching scientific notation (e.g. 1.5e-6). Reference
Capturing significand and exponent separately.

([-+]?\d*\.?\d+)(?:[eE]([-+]?\d+))?

Capturing the entire string together.

([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)