Regular Expressions 101

Save & Share

  • Regex Version: ver. 3
  • Update Regex
    ctrl+⇧+s
  • Save new Regex
    ctrl+s
  • Add to Community Library

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8
  • .NET 7.0 (C#)
  • Rust
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests

Tools

Sponsors
There are currently no sponsors. Become a sponsor today!
An explanation of your regex will be automatically generated as you type.
Detailed match information will be displayed here automatically.
  • All Tokens
  • Common Tokens
  • General Tokens
  • Anchors
  • Meta Sequences
  • Quantifiers
  • Group Constructs
  • Character Classes
  • Flags/Modifiers
  • Substitution
  • A single character of: a, b or c
    [abc]
  • A character except: a, b or c
    [^abc]
  • A character in the range: a-z
    [a-z]
  • A character not in the range: a-z
    [^a-z]
  • A character in the range: a-z or A-Z
    [a-zA-Z]
  • Any single character
    .
  • Alternate - match either a or b
    a|b
  • Any whitespace character
    \s
  • Any non-whitespace character
    \S
  • Any digit
    \d
  • Any non-digit
    \D
  • Any word character
    \w
  • Any non-word character
    \W
  • Non-capturing group
    (?:...)
  • Capturing group
    (...)
  • Zero or one of a
    a?
  • Zero or more of a
    a*
  • One or more of a
    a+
  • Exactly 3 of a
    a{3}
  • 3 or more of a
    a{3,}
  • Between 3 and 6 of a
    a{3,6}
  • Start of string
    ^
  • End of string
    $
  • A word boundary
    \b
  • Non-word boundary
    \B

Regular Expression

/
/
gm

Test String

Code Generator

Generated Code

#include <StringConstants.au3> ; to declare the Constants of StringRegExp #include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate Local $sRegex = "(?m)intensity\"\s*:\s*\(\"\w+\"\s*:\s*(?<intensity>\d+)" Local $sString = "("data": ["from" :" & @CRLF & _ ""2024-04-25T11: 30Z"," & @CRLF & _ ""to": "2024-04-2512:00Z"," & @CRLF & _ ""intensity": ("forecast": 152," & @CRLF & _ ""actual": null, "index": "moderate"}), ("from": "2024-04-25T12:002"," & @CRLF & _ ""intensity": {"forecast": 152, "actual": null, "index": "moderate"}), ("from": "2024-04-25T12:30Z"," & @CRLF & _ ""to":" & @CRLF & _ "{"from": "2024-04-25T13:00Z", "to":" & @CRLF & _ ""2024-04-25T12: 30Z"," & @CRLF & _ "("forecast": 164," & @CRLF & _ ""actual": null," & @CRLF & _ ""2024-04-2513: 30Z", "intensity": ("forecast": 154," & @CRLF & _ ""to": "2024-04-25T13: 002"," & @CRLF & _ ""intensity": ("forecast": 154," & @CRLF & _ ""actual": null," & @CRLF & _ ""index":" & @CRLF & _ ""actual": null, "index": "moderate"}), ("from": "2024-04-25T13:30Z*, "to": "2024-04-25T14:002"," & @CRLF & _ ""moderate"}}," & @CRLF & _ ""intensity":" & @CRLF & _ "04-25T14: 30Z"," & @CRLF & _ ""to" :" & @CRLF & _ ""index": "moderate"3}, ("from": "2024-04-25T14:002*, "to": "2024-04-25T14:30Z", "intensity": ("forecast": 166, "actual": null, "index": "moderate"}), ("from":" & @CRLF & _ "" 2024-04-25T15:00Z"" & @CRLF & _ ""actual": nu11," & @CRLF & _ ""index"" & @CRLF & _ ""intensity": {"forecast": 170, "actual": null, "index": "moderate"}), {"from": "2024-04-2515: 00Z"," & @CRLF & _ "2024-" & @CRLF & _ ""to" :" & @CRLF & _ ""moderate"}), {"from": "2024-04-25T15:30Z", "to": "2024-04-25T16:00Z", "intensity": ("forecast": 175," & @CRLF & _ ""to": "2024-04-25T15: 30Z"," & @CRLF & _ ""intensity": {"forecast": 172," & @CRLF & _ ""2024-04-25T16: 30Z"," & @CRLF & _ ""index": "moderate"}}, ("from": "2024-04-25T17:00Z", "to":" & @CRLF & _ ""intensity": ("forecast": 177, "actual": null, "index": "moderate"?), ("from": "2024-04-2516: 302"," & @CRLF & _ ""actual" : nu11," & @CRLF & _ ""index"" & @CRLF & _ ""moderate"}}, ("from": "2024-04-2516: 00Z"," & @CRLF & _ ""to": "2024-04-25T17:002"," & @CRLF & _ ""intensity": ("forecast": 179," & @CRLF & _ ""actual": null," & @CRLF & _ "2024-04-2517: 30Z", "intensity": ("forecast": 181, "actual": null," & @CRLF & _ "25T18:00Z", "intensity": ("forecast": 184," & @CRLF & _ ""index": "moderate"}}, {"from": "2024-04-25T17: 30Z"," & @CRLF & _ ""actual": null, "index": "moderate"}), ("from": "2024-04-25T18:002", "to": "2024-04-25T18: 30Z"," & @CRLF & _ ""to": "2024-04-" & @CRLF & _ ""moderate"}}, ("from": "2024-04-2518: 30Z", "to": "2024-04-25T19:002"," & @CRLF & _ ""intensity": ("forecast": 187, "actual": null," & @CRLF & _ ""intensity": ("forecast": 190," & @CRLF & _ ""actua1": nul1," & @CRLF & _ ""index":" & @CRLF & _ ""index":" & @CRLF & _ ""high"}}, ("from":" & @CRLF & _ ""intensity": {"forecast": 193," & @CRLF & _ ""actual": null, "index":" & @CRLF & _ ""2024-04-25T19: 00Z", "to":" & @CRLF & _ ""2024-04-25T19: 30Z"" & @CRLF & _ ""high"}}, ("from": "2024-04-25T19:30Z", "to": "2024-04-25T20:00Z", "intensity":" & @CRLF & _ "{"forecast": 194," & @CRLF & _ ""2024-04-2520: 00Z", "to": "2024-04-25T20:30Z", "intensity": {"forecast": 195, "actual": null, "index": "high"3}, ("from": "2024-04-25T20:30Z"," & @CRLF & _ ""actual": null, "index": "high")}, ("from":" & @CRLF & _ ""2024-04-25T21:00Z", "intensity": ("forecast":" & @CRLF & _ "198, "actual": null, "index": "high"'), ("from": "2024-04-25T21: 002"," & @CRLF & _ ""2024-04-25T22: 00Z", "intensity": {"forecast": 187, "actual": null," & @CRLF & _ ""to": "2024-04-25T21: 30Z", "intensity": {"forecast": 196," & @CRLF & _ "'actual": null," & @CRLF & _ ""index": "high"}}, {"from": "2024-04-25T21:302"" & @CRLF & _ ""to"" & @CRLF & _ ""index": "moderate"}}, ("from": "2024-04-25T22:00Z", "to":" & @CRLF & _ ""2024-04-25T22: 30Z"," & @CRLF & _ ""intensity": ("forecast": 181, "actual": null," & @CRLF & _ ""index": "moderate"}}, {"from": "2024-04-25T22:30Z", "to": "2024-04-25T23:002", "intensity": ("forecast": 180, "actual": null," & @CRLF & _ ""index'" & @CRLF & _ "moderate"}},{"from":" & @CRLF & _ "25T23:30Z", "intensity": {"forecast": 172, "actual": null, "index": "moderate"}}, {"from": "2024-04-25T23: 30Z"," & @CRLF & _ ""2024-04-25T23:002"," & @CRLF & _ ""to":" & @CRLF & _ "" 2024-04-" & @CRLF & _ ""moderate"}}, {"from": "2024-04-26T00:00Z", "to": "2024-04-2600: 30Z", "intensity": ("forecast": 150," & @CRLF & _ ""to": "2024-04-2600: 00Z"," & @CRLF & _ ""intensity": ("forecast": 150," & @CRLF & _ ""actual": null," & @CRLF & _ ""index":" & @CRLF & _ ""actual": null, "index": "moderate")}, ("from": "2024-04-26T00: 302"," & @CRLF & _ ""to": "2024-04-26T01:00Z"" & @CRLF & _ ""intensity": {"forecast": 149," & @CRLF & _ ""actual": null," & @CRLF & _ ""index": "moderate"}}, ("from": "2024-04-26T01:002"," & @CRLF & _ ""to": "2024-04-26T01:30Z", "intensity": {"forecast": 149," & @CRLF & _ ""actual": null," & @CRLF & _ ""index":" & @CRLF & _ ""moderate"}}, ..." Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH) Local $aFullArray[0] For $i = 0 To UBound($aArray) -1 _ArrayConcatenate($aFullArray, $aArray[$i]) Next $aArray = $aFullArray ; Present the entire match result _ArrayDisplay($aArray, "Result")

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 AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm