Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • 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){(\n*.*\n*)}" Local $sString = "2019-03-06 16:17:27 INF Creating container.\r\n2019-03-06 16:17:27 INF Container name : [lalaland]\r\n2019-03-06 16:17:28 INF Get or Create operation executed successfully.\r\n{\r\n \"data\": {\r\n \"command\": \"/usr/sbin/boot.sh\",\r\n \"created\": 1551838866,\r\n \"hostConfig\": {\r\n \"autoRemove\": false,\r\n \"binds\": null,\r\n \"blkioDeviceReadBps\": null,\r\n \"blkioDeviceReadIOps\": null,\r\n \"blkioDeviceWriteBps\": null,\r\n \"blkioDeviceWriteIOps\": null,\r\n \"blkioWeight\": 0,\r\n \"blkioWeightDevice\": null,\r\n \"capAdd\": null,\r\n \"capDrop\": null,\r\n \"cgroup\": null,\r\n \"cgroupParent\": null,\r\n \"consoleSize\": null,\r\n \"containerIDFile\": null,\r\n \"cpuCount\": 0,\r\n \"cpuPercent\": 0,\r\n \"cpuPeriod\": 0,\r\n \"cpuQuota\": 0,\r\n \"cpuRealtimePeriod\": 0,\r\n \"cpuRealtimeRuntime\": 0,\r\n \"cpuShares\": 0,\r\n \"cpusetCpus\": null,\r\n \"cpusetMems\": null,\r\n \"deviceCgroupRules\": null,\r\n \"devices\": null,\r\n \"diskQuota\": 0,\r\n \"dns\": null,\r\n \"dnsOptions\": null,\r\n \"dnsSearch\": null,\r\n \"extraHosts\": null,\r\n \"groupAdd\": null,\r\n \"ioMaximumBandwidth\": 0,\r\n \"ioMaximumIOps\": 0,\r\n \"ipcMode\": null,\r\n \"isolation\": null,\r\n \"kernelMemory\": 0,\r\n \"links\": null,\r\n \"logConfig\": null,\r\n \"memory\": 0,\r\n \"memoryReservation\": 0,\r\n \"memorySwap\": 0,\r\n \"memorySwappiness\": null,\r\n \"nanoCpus\": 0,\r\n \"networkMode\": \"default\",\r\n \"oomKillDisable\": false,\r\n \"oomScoreAdj\": 0,\r\n \"pidMode\": null,\r\n \"pidsLimit\": 0,\r\n \"portBindings\": null,\r\n \"privileged\": false,\r\n \"publishAllPorts\": false,\r\n \"readonlyRootfs\": false,\r\n \"restartPolicy\": null,\r\n \"runtime\": null,\r\n \"securityOpt\": null,\r\n \"shmSize\": 0,\r\n \"utsMode\": null,\r\n \"ulimits\": null,\r\n \"usernsMode\": null,\r\n \"volumeDriver\": null,\r\n \"volumesFrom\": null\r\n },\r\n \"id\": \"a1fc854544650ec93a1e6964b9de0f045d62618f107056b20abcf0dc4ae0f61a\",\r\n \"image\": \"solace/solace-pubsub-standard:latest\",\r\n \"imageID\": \"sha256:4be92bf62c8526d684d7e45e1db27413b8b5f6f556a5ed3552fb292ee1368cd6\",\r\n \"mounts\": [\r\n {\r\n \"destination\": \"/usr/sw/jail\",\r\n \"driver\": \"local\",\r\n \"mode\": \"\",\r\n \"name\": \"86ef434be868d57068a98056d84b78210452987eebe8794c01bb81a99f0b0ed0\",\r\n \"propagation\": \"\",\r\n \"rw\": true,\r\n \"source\": \"\",\r\n \"type\": \"volume\"\r\n },\r\n {\r\n \"destination\": \"/usr/sw/var\",\r\n \"driver\": \"local\",\r\n \"mode\": \"\",\r\n \"name\": \"a816e052177bf96b27b85b8f08667ac04dd0a61fe8a0704872d0056183bb1a90\",\r\n \"propagation\": \"\",\r\n \"rw\": true,\r\n \"source\": \"\",\r\n \"type\": \"volume\"\r\n },\r\n {\r\n \"destination\": \"/usr/sw/adb\",\r\n \"driver\": \"local\",\r\n \"mode\": \"\",\r\n \"name\": \"3c999fe711a0f67b3ba76f28275a45184b388714520b1325cea2c9487c22f84e\",\r\n \"propagation\": \"\",\r\n \"rw\": true,\r\n \"source\": \"\",\r\n \"type\": \"volume\"\r\n },\r\n {\r\n \"destination\": \"/usr/sw/internalSpool\",\r\n \"driver\": \"local\",\r\n \"mode\": \"\",\r\n \"name\": \"63ede5a141e08d7aca52b474d2f4f3694ddff1dcb0085b356c4ed26597095b57\",\r\n \"propagation\": \"\",\r\n \"rw\": true,\r\n \"source\": \"\",\r\n \"type\": \"volume\"\r\n },\r\n {\r\n \"destination\": \"/usr/sw/internalSpool/softAdb\",\r\n \"driver\": \"local\",\r\n \"mode\": \"\",\r\n \"name\": \"146dc96e171076cb165ea046508713c04dc9557002510ab2c37fb54283c2fbf1\",\r\n \"propagation\": \"\",\r\n \"rw\": true,\r\n \"source\": \"\",\r\n \"type\": \"volume\"\r\n }\r\n ],\r\n \"names\": [\r\n \"lalaland\"\r\n ],\r\n \"networkSettings\": {\r\n \"bridge\": null,\r\n \"endpointID\": null,\r\n \"gateway\": null,\r\n \"globalIPv6Address\": null,\r\n \"globalIPv6PrefixLen\": 0,\r\n \"hairpinMode\": false,\r\n \"ipAddress\": null,\r\n \"ipPrefixLen\": 0,\r\n \"iPv6Gateway\": null,\r\n \"linkLocalIPv6Address\": null,\r\n \"linkLocalIPv6PrefixLen\": 0,\r\n \"macAddress\": null,\r\n \"networks\": {\r\n \"bridge\": {\r\n \"aliases\": null,\r\n \"driverOpts\": null,\r\n \"endpointID\": \"513a9f23ea2852614e556d61ce13b8cde38da27563de5f9978acf59f7a1834f3\",\r\n \"gateway\": \"172.17.0.1\",\r\n \"globalIPv6Address\": \"\",\r\n \"globalIPv6PrefixLen\": 0,\r\n \"ipamConfig\": null,\r\n \"ipAddress\": \"172.17.0.5\",\r\n \"ipPrefixLen\": 16,\r\n \"iPv6Gateway\": \"\",\r\n \"links\": null,\r\n \"macAddress\": \"02:42:ac:11:00:05\",\r\n \"networkID\": \"e60ce3b2bf4eb3767372dd896f4a34d147d24e18cfa691aa2d5a152c436050ad\"\r\n }\r\n },\r\n \"ports\": null,\r\n \"sandboxID\": null,\r\n \"sandboxKey\": null,\r\n \"secondaryIPAddresses\": null,\r\n \"secondaryIPv6Addresses\": null\r\n },\r\n \"ports\": [\r\n {\r\n \"privatePort\": 2222,\r\n \"type\": \"tcp\",\r\n \"ip\": null,\r\n \"publicPort\": null\r\n },\r\n {\r\n \"privatePort\": 55555,\r\n \"type\": \"tcp\",\r\n \"ip\": \"0.0.0.0\",\r\n \"publicPort\": 11318\r\n },\r\n {\r\n \"privatePort\": 8080,\r\n \"type\": \"tcp\",\r\n \"ip\": \"0.0.0.0\",\r\n \"publicPort\": 10505\r\n }\r\n ],\r\n \"state\": \"running\",\r\n \"solaceMessagingConnectionString\": \"tcp://cap-docker-poc:11318\",\r\n \"solaceManagementConnectionString\": \"tcp://cap-docker-poc:10505\",\r\n \"isConnectionToSolaceClientOk\": true,\r\n \"containerStatus\": null,\r\n \"messages\": null,\r\n \"success\": 0\r\n },\r\n \"result\": 0\r\n}\r\n" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "{ test : test }" & @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