Regular Expressions 101

Save & Share

  • Save Regex
    ctrl+s
  • Update Regex
    ctrl+⇧+s

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8

Function

  • Match
  • Substitution
  • List
  • Unit Tests
/
^(\d+\.?\d*[fF]|\d+\.?(?![\p{L}_])\d*[fF]?|\d*\.\d+[fF]?)
/
uimg
^ asserts position at start of a line
1st Capturing Group
(\d+\.?\d*[fF]|\d+\.?(?![\p{L}_])\d*[fF]?|\d*\.\d+[fF]?)
1st Alternative
\d+\.?\d*[fF]
\d
matches a digit zero through nine in any script except ideographic scripts (equivalent to \p{Nd})
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\.
matches the character . with index 4610 (2E16 or 568) literally (case insensitive)
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\d
matches a digit zero through nine in any script except ideographic scripts (equivalent to \p{Nd})
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Match a single character present in the list below
[fF]
fF
matches a single character in the list fF (case insensitive)
2nd Alternative
\d+\.?(?![\p{L}_])\d*[fF]?
\d
matches a digit zero through nine in any script except ideographic scripts (equivalent to \p{Nd})
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\.
matches the character . with index 4610 (2E16 or 568) literally (case insensitive)
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
Negative Lookahead
(?![\p{L}_])
Assert that the Regex below does not match
Match a single character present in the list below
[\p{L}_]
\p{L} matches any kind of letter from any language
_ matches the character _ with index 9510 (5F16 or 1378) literally (case insensitive)
\d
matches a digit zero through nine in any script except ideographic scripts (equivalent to \p{Nd})
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Match a single character present in the list below
[fF]
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
fF
matches a single character in the list fF (case insensitive)
3rd Alternative
\d*\.\d+[fF]?
\d
matches a digit zero through nine in any script except ideographic scripts (equivalent to \p{Nd})
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\. matches the character . with index 4610 (2E16 or 568) literally (case insensitive)
\d
matches a digit zero through nine in any script except ideographic scripts (equivalent to \p{Nd})
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
Match a single character present in the list below
[fF]
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
fF
matches a single character in the list fF (case insensitive)
Global pattern flags
u modifier: unicode. Pattern strings are treated as UTF-16. Also causes escape sequences to match unicode characters
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
g modifier: global. All matches (don't return after first match)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
uimg

Test String

Code Generator

Generated Code

Loading code sample...
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report.
For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php