Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
Sponsors
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
Processing...

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)^\s*(\d+)?\s?([rwxSTstdcb\-lp?]{10})\s+(\d+)?\s?(\S+)\s+(\S+)\s+([0-9,]+)?\s+(\d+)?\s?([0-9\-]{10}\s+[0-9:]{5}|[A-Z][a-z]{2}\s+[0-9]{1,2}\s+[0-9:]{4,5})\s((?:(?!\s\->\s).)*)(\s\->\s)?(.*)" Local $sString = "busybox ls -lain" & @CRLF & _ " 1769542 -rw------- 1 10163 10163 0 Dec 13 21:06 0.txt" & @CRLF & _ " 1769543 -rw------- 1 10163 10163 0 Nov 13 21:06 1.txt" & @CRLF & _ "1769561 -rw------- 1 10163 10163 0 Feb 13 2016 10.txt" & @CRLF & _ "1769562 -rw------- 1 10163 10163 0 Jan 13 2016 11.txt" & @CRLF & _ "1769544 -rw------- 1 10163 10163 0 Oct 13 21:06 2.txt" & @CRLF & _ "1769545 -rw------- 1 10163 10163 0 Sep 13 21:06 3.txt" & @CRLF & _ "1769546 -rw------- 1 10163 10163 0 Aug 13 21:06 4.txt" & @CRLF & _ "1769547 -rw------- 1 10163 10163 0 Jul 13 21:06 5.txt" & @CRLF & _ "1769550 -rw------- 1 10163 10163 0 Jun 13 2016 6.txt" & @CRLF & _ "1769552 -rw------- 1 10163 10163 0 May 13 2016 7.txt" & @CRLF & _ "1769559 -rw------- 1 10163 10163 0 Apr 13 2016 8.txt" & @CRLF & _ "1769560 -rw------- 1 10163 10163 0 Mar 13 2016 9.txt" & @CRLF & _ "" & @CRLF & _ "toolbox ls -l" & @CRLF & _ "drwxr-xr-x root root 1970-03-01 01:33 acct" & @CRLF & _ "drwxrwx--- system cache 2016-12-13 10:53 cache" & @CRLF & _ "lrwxrwxrwx root root 1969-12-31 16:00 charger -> /sbin/healthd" & @CRLF & _ "dr-x------ root root 1970-03-01 01:33 config" & @CRLF & _ "lrwxrwxrwx root root 1970-03-01 01:33 d -> /sys/kernel/debug" & @CRLF & _ "drwxrwx--x system system 2016-07-06 21:19 data" & @CRLF & _ "-rw-r--r-- root root 614 1969-12-31 16:00 default.prop" & @CRLF & _ "drwxr-xr-x root root 2016-12-10 00:23 dev" & @CRLF & _ "lrwxrwxrwx root root 1970-03-01 01:33 etc -> /system/etc" & @CRLF & _ "-rw-r--r-- root root 24061 1969-12-31 16:00 file_contexts" & @CRLF & _ "dr-xr-x--- system system 1969-12-31 16:00 firmware" & @CRLF & _ "-rw-r----- root root 4158 1969-12-31 16:00 fstab.angler" & @CRLF & _ "-rwxr-x--- root root 1142576 1969-12-31 16:00 init" & @CRLF & _ "-rwxr-x--- root root 98 1969-12-31 16:00 init.angler.diag.rc" & @CRLF & _ "-rwxr-x--- root root 14044 1969-12-31 16:00 init.angler.rc" & @CRLF & _ "-rwxr-x--- root root 524 1969-12-31 16:00 init.angler.sensorhub.rc" & @CRLF & _ "-rwxr-x--- root root 9729 1969-12-31 16:00 init.angler.usb.rc" & @CRLF & _ "-rwxr-x--- root root 941 1969-12-31 16:00 init.environ.rc" & @CRLF & _ "" & @CRLF & _ "toybox ls -la" & @CRLF & _ "drwxr-xr-x 20 root root 0 1970-03-01 01:33 ." & @CRLF & _ "drwxr-xr-x 20 root root 0 1970-03-01 01:33 .." & @CRLF & _ "drwxr-xr-x 235 root root 0 1970-03-01 01:33 acct" & @CRLF & _ "drwxrwx--- 5 system cache 4096 2016-12-13 21:57 cache" & @CRLF & _ "" & @CRLF & _ "busybox ls -la /dev" & @CRLF & _ "crw-rw---- 1 system camera 81, 4 1970-01-30 15:02 v4l-subdev3" & @CRLF & _ "crw-rw---- 1 system camera 81, 5 1970-01-30 15:02 v4l-subdev4" & @CRLF & _ "crw-rw---- 1 system camera 81, 6 1970-01-30 15:02 v4l-subdev5" & @CRLF & _ "crw-rw---- 1 system camera 81, 7 1970-01-30 15:02 v4l-subdev6" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" 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