Regular Expressions 101

Save & Share

  • Regex Version: ver. 8
  • 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)(?<! - )((?:Jul|Aug)\W\d+\W+\d+)(?!.*(?:Jul|Aug)\W\d+\W+\d+)" Local $sString = "Jul 31, 2015 - Aug 27, 2015   |   " & @CRLF & _ "Itinerary # 1110473023685       Amman (AMM) ? Chicago (ORD) Jul 31, 2015 - Aug 27, 2015 , 1 round trip ticket  " & @CRLF & _ "NOT BOOKED This flight is not booked. Book now to guarantee price and availability. " & @CRLF & _ "Traveler Information Adult No frequent flyer details provided " & @CRLF & _ "* Seat assignments, special meals, frequent flyer point awards and special assistance requests should be confirmed directly with the airline." & @CRLF & _ "Jul 31, 2015 - Departure 2 stops Total travel time:20 h 40 m " & @CRLF & _ "Amman Paris 5 h 0 m 2,097 mi AMM  1:30am CDG  5:30am   Terminal 2E   Airport check-in with Air France Delta  8429 Operated by Air France Economy / Coach (B)" & @CRLF & _ "" & @CRLF & _ "aris Amsterdam 1 h 15 m 247 mi CDG  8:45am Terminal 2F AMS  10:00am     Delta  9429 Operated by KLM Economy / Coach (B) | Confirm seats with the airline " & @CRLF & _ "* Layover: 2 h 40 m " & @CRLF & _ "Amsterdam Chicago 8 h 30 m 4,112 mi AMS  12:40pm ORD  2:10pm   Terminal 5   Delta  9382 Operated by KLM Economy / Coach (B) | Confirm seats with the airline " & @CRLF & _ "* Aug 26, 2015 - Return 1 stop Total travel time:19 h 0 m Chicago " & @CRLF & _ "Paris 8 h 15 m 4,148 mi ORD  5:20pm Terminal 5 CDG  8:35am +1 day   Terminal 2E   Air France  489 Economy / Coach (N) | Confirm seats with the airline " & @CRLF & _ "* Layover: 6 h 10 m Paris Amman 4 h 35 m 2,097 mi CDG  2:45pm Terminal 2E AMM  8:20pm   (Arrives on Aug 27, 2015)   " & @CRLF & _ "Air France  3840 Economy / Coach (N) | Confirm seats with the airline * Airline Rules & Regulations ·         " & @CRLF & _ "This price includes a nonrefundable booking fee. ·         " & @CRLF & _ "We understand that sometimes plans change. We do not charge a cancel or change fee. When the airline charges such fees in accordance with its own polic" & @CRLF & _ "ies, the cost will be passed on to you. · " & @CRLF & _ "nonstop" & @CRLF & _ "" & @CRLF & _ "Price Summary Traveler 1: Adult   $1,901.20 Flight   $1,267.00 Taxes & Fees   $634.20 Expedia Booking Fee   $7.00 Total: $1,908.20 All prices quoted in US dollars.     " 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