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
/
\s(?=[^\s]+(.*?GHz)$)
/
ig
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
Positive Lookahead
(?=[^\s]+(.*?GHz)$)
Assert that the Regex below matches
Match a single character not present in the list below
[^\s]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
1st Capturing Group
(.*?GHz)
.
matches any character (except for line terminators)
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
GHz
matches the characters GHz literally (case insensitive)
$ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
Global pattern flags
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
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

/
/
ig

Test String