Jarextor: JavaScript Regular Expression Testor

Last modified on

JAREXTOR

notifier #1
notifier #2
Jarextor

Example

  • On the left (pattern) input, type /a/ (finding "a" character)
  • On (small) right (flag) input, type g (global)
You'll see the result.

Other examples

  1. Matching URL protocol, either http:// or https://
    /https?:\/\//g
    • The s? means the character s is optional, 0 or 1 repetition.
    • We need to escape the slash (/) with backslash. Thus the // becomes \/\/
  2. Finding all "t" character and case insensitive (additional i flag):
    /t/gi
  3. Finding all double "t"s:
    /t{2}/g
  4. Finding all words starting with "t" and have "g" as the tail. And also case insensitive:
    /t[a-z]+g/gi
    • [] is the bracket to match any character within it.
    • a-z means match any alphabet (lowercase a through z).
    • The + meta-character is to match the preceding character (which is "[a-z]") one or more times. So it can be one character or a group of characters.
  5. Finding all words (with only alphabet) which don't have "t" in it and using case insensitive flag:
    /\b[^t\s\W\d_]+\b/gi
    • \b at the front and back are to match word boundaries.
    • ^ within the bracket is to match other characters than the ones defined inside it: t, \s, \W, \d, and character _ (underscrore).
    • The \s meta-character is whitespace (horizontal/vertical, tab, etc).
    • The \W meta-character is to match non-word.
    • The \d meta-character is to match digit (number).
    It can be also simplified as /\b[a-su-z]+\b/gi or maybe others.

Please use input characters without being wrapped in <...>.

Jarextor