Regular Expressions 101

Save & Share

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
No Match

r"
"
gmi

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 = "(?mi)^\w[a-z][^\d:\n]+$\s[a-z][^\d]+((-[\d,]+|[\d,]+)\s(\s+)?(-[\d,]+|[\d,]+).*)" Local $sString = "RM RM" & @CRLF & _ "CASH FLOWS FROM/(FOR) OPERATING ACTIVITIES" & @CRLF & _ "Profit before tax 96,261,457 75,615,413 23,786,496 17,519,528" & @CRLF & _ "Adjustments for:" & @CRLF & _ "Depreciation of property, plant and" & @CRLF & _ "equipment 15,777,521 17,300,505 17,205 17,331" & @CRLF & _ "Depreciation of right-of-use assets 2,040,669 0 94,956 0" & @CRLF & _ "Interest expense 755,525 568,006 9,480 56,109" & @CRLF & _ "Unrealised (gain)/loss on foreign exchange (81,588) (616,303) 20,673 190,487" & @CRLF & _ "Allowance for impairment losses on amount" & @CRLF & _ "owing by subsidiaries 0 0 0 1,242,999" & @CRLF & _ "Allowance for impairment losses on" & @CRLF & _ "receivables 0 932,838 0 0" & @CRLF & _ "Bad debt written off 0 153,130 0 0" & @CRLF & _ "Gain on disposal of an associate 0 (672,207) 0 0" & @CRLF & _ "Property, plant and equipment written off 35 10,678 0 0" & @CRLF & _ "Share of results in an associate 0 (78,115) 0 0" & @CRLF & _ "Interest income (1,150,023) (917,220) (455,564) (549,987)" & @CRLF & _ "Gain on disposal of property, plant" & @CRLF & _ "and equipment (14,417) (164,099) 0 0" & @CRLF & _ "Writeback of allowance for impairment losses" & @CRLF & _ "on amount owing by subsidiaries 0 0 (271,455) 0" & @CRLF & _ "Writeback of allowance for impairment losses" & @CRLF & _ "on trade receivables (2,200) (10,000) 0 0" & @CRLF & _ "Dividend income from subsidiaries 0 0 (28,541 ,623) (23,527,968)" & @CRLF & _ "Operating Profit/(Loss) Before" & @CRLF & _ "Working Capital Changes 113,586,979 92,122,626 (5,339,832) (5,051,501)" & @CRLF & _ "Increase)/Decrease in:" & @CRLF & _ "Inventories (1,274,623) (379,713) 0 0" & @CRLF & _ "Trade receivables 20,924,616 (16,590,199) 0 0" & @CRLF & _ "Other receivables and prepaid expenses (564,806) (1,492,450) (3,691) (27,867)" & @CRLF & _ "Amount owing by an associate 0 1,330,780 0 0" & @CRLF & _ "Decrease)/Increase in:" & @CRLF & _ "Trade payables (1,313,328) (826,277) 0 0" & @CRLF & _ "Other payables and accrued expenses 3,319,226 3,376,361 503,145 1,190,933" & @CRLF & _ "Cash Generated From/(For) Operations 134,678,064 77,541,128 (4,840,378) (3,888,435)" & @CRLF & _ "Taxes paid (19,777,287) (14,218,858) 0 0" & @CRLF & _ "Net Cash From/(For) Operating Activities 114,900,777 63,322,270 (4,840,378) (3,888,435)" & @CRLF & _ "The accompanying NOTEs form an integral part of these Financial Statements." & @CRLF & _ "Frontken STEAL BERGHE Sais 57" & @CRLF & _ "Statements Of Cash Flows" & @CRLF & _ "For The Financial Year Ended 31 December 2019 (cont’d)" & @CRLF & _ "The Group The Company" & @CRLF & _ "2019 2018 2019 2018" & @CRLF & _ "RM RM" & @CRLF & _ "CASH FLOWS (FOR)/FROM INVESTING ACTIVITIES" & @CRLF & _ "Repayment from subsidiaries 0 0 271,455 1,514,464" & @CRLF & _ "Purchase of property, plant and equipment (7,016,576) (7,492,297) 0 (3,689)" & @CRLF & _ "Addition of right-of-use assets (15,434) 0 0 0" & @CRLF & _ "Dividend received from subsidiaries 0 0 28,038,195 21,039,335" & @CRLF & _ "Additional investment/acquisition of" & @CRLF & _ "subsidiaries (2,636,981) (7,133,082) (2,636,981) (7,133,082)" & @CRLF & _ "Proceeds from disposal of an associate 0 2,496,557 0 0" & @CRLF & _ "Pro (ceeds)/from disposal of property, plant" & @CRLF & _ "and equipment 14,901 1,077,256 0 0" & @CRLF & _ "Net (placement)/withdrawal of fixed" & @CRLF & _ "deposits with licensed banks (3,608,920) 2,992,578 0 1,104,683" & @CRLF & _ "Interest received 1,150,023 917,220 455,564 549,987" & @CRLF & _ "Net Cash (For)/From Investing Activities (12,112,987) (7,141,768) 26,128,233 17,071,698" & @CRLF & _ "CASH FLOWS FOR FINANCING ACTIVITIES" & @CRLF & _ "Decrease)/Increase in amount owing" & @CRLF & _ "to subsidiaries 0 0 (4,851,365) 591,745" & @CRLF & _ "Repayment of term loans (10,677,444) (16,712,117) 0 (2,037,933)" & @CRLF & _ "Interest paid (755,525) (568,006) (9,480) (56,109)" & @CRLF & _ "Dividend paid by the Company (18,863,433) (7,335,779) (18,863,433) (7,335,779)" & @CRLF & _ "Dividend paid by 0 subsidiary to non-" & @CRLF & _ "controlling interests (1,048,152) (2,626,027) 0 0" & @CRLF & _ "Payment of hire purchase payables 0 (544,511) 0 0" & @CRLF & _ "Payment of lease liabilities (2,366,158) 0 (92,640) 0" & @CRLF & _ "Net Cash For Financing Activities (33,710,712) (27,786,440) (23,816,918) (8,838,076)" & @CRLF & _ "NET INCREASE/(DECREASE) IN CASH AND" & @CRLF & _ "CASH EQUIVALENTS 69,077,078 28,394,062 (2,529,063) 4,345,187" & @CRLF & _ "Effect of exchange rate changes 1,651,600 293,086 (59,241) 8,004" & @CRLF & _ "CASH AND CASH EQUIVALENTS" & @CRLF & _ "AT BEGINNING OF YEAR 148,940,067 120,252,919 14,110,208 9,757,017" & @CRLF & _ "CASH AND CASH EQUIVALENTS" & @CRLF & _ "AT END OF YEAR 219,668,745 148,940,067 11,521,904 14,110,208" 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