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)\b(?<!\.)[!#$%&'*+\-/=?^_`{|}~\w][!#$%&'*+\-/=?^_`{|}~\.\w]{0,}[!#$%&'*+\-/=?^_`{|}~\w][@]\w+(?:[-.]\w+)*" Local $sString = "Check this one too for my friend: a&d@somedomain.com" & @CRLF & _ "This looks weired but it is valid email a*d@somedomain.com" & @CRLF & _ "Same here really odd one - a/d@somedomain.com" & @CRLF & _ "What can you say for this one huh ? tim@yahoo.abc.com" & @CRLF & _ "Non-Matches:" & @CRLF & _ "This is invalid _ .abc@somedomain.com" & @CRLF & _ "Not at all valid abc.@somedomain.com" & @CRLF & _ "angle brackates are not allowed too a>b@somedoma" & @CRLF & _ "" & @CRLF & _ "visa, last 4 digits 3208; my dob is 12/31" & @CRLF & _ "this afternoon the 800 number. I live" & @CRLF & _ "number (ending in 6436), however it has a cvv to capture." & @CRLF & _ "that a payment on 5183 is due 6/21. I am prepared to get my cvv" & @CRLF & _ "was sent ending in 4859 does not work" & @CRLF & _ "check it, my ID is 411978813 not present in my data." & @CRLF & _ "my number is _84 24 028458888 they gave a reference" & @CRLF & _ "Vregistration number 280757578 and having another data is also available." & @CRLF & _ "confirmation code 100453052 and ave yet to get those details in to my account" & @CRLF & _ "my number again : +55(11)995149340 thanks and regards" & @CRLF & _ "has an item number 253778620 please can you project this details to client." & @CRLF & _ "it card ending in 7656 never receive the pin for my cc card details." & @CRLF & _ "my card pin not received but I arrive october 16 2018 thru UPS but until" & @CRLF & _ "My old passwOrD was kufd87jhj_)kj" & @CRLF & _ "Pin: 901608 7383 psdwd is p6%ss_09gt^4v}" & @CRLF & _ "Mobile unlock key for user_1 is: 7305q-efd0t-0i2i7 and" & @CRLF & _ "for user_2 is fgth8d-c7760-wwrb3 and the password for user_1 is gth8d_kj212" & @CRLF & _ "The CEO's UUID is provided here - 7FC747F5-FB0D-4065-82B1-3F38D2988ECE and" & @CRLF & _ "the COO's is also provided: 31EB3A28-896A-40C2-B0BE-0C21EA3F4FBB4" & @CRLF & _ "My ipv4 address is 392.168.0.42; but 192.168.0.420 is not an address." & @CRLF & _ "The hacker's ip is 168.212.226.204 and he has no idea that I who's ip is not " & @CRLF & _ "Here are some ipv6 hosts which I'll be using to confuse the hacker: fe80::1 or 2342:32fd::2d32" & @CRLF & _ "fe80:33333::1ff:fe23:4567:890a this is invalid ip and my pswd: h_08$#fRdc54@" & @CRLF & _ "ohn, please get that article on www.linkedin.com to me by 5:00PM or 7th of December 1976" & @CRLF & _ "If you have any other plans on February 16th then let me know or on 15/02/2009 and " & @CRLF & _ "My birthday is on 12th of oct and my wife's date of birth is december 39, 1991" & @CRLF & _ "You can reach me at (519)-236-2723x341 or get in touch with my associate at harold.smith@gmail.com" & @CRLF & _ "Here is your new TsyS_passwrd: 1LK2XP0S and the system pswd is nwfun&b_08G" & @CRLF & _ "Here is your new tsYs-paSswOrd - NsoCxbo4 and the passwrd is pass_09Hg54v}" & @CRLF & _ "my person no. is 67542090 and nbk is zk87ghY but my friend's nbk starts from nb which is nbh768i" & @CRLF & _ "please go to this link and upload your documents - http://www.bofa.com/" & @CRLF & _ "follow this link: https://www.ml.com/ and make a payment of $35.00" & @CRLF & _ "click on this link and get hacked banofamerica.com/page1/hacked/" & @CRLF & _ "this is official website www.bankofamerica.com" & @CRLF & _ "your loan file number is pfm657890345120 and loan balance is $34,67.89" & @CRLF & _ "loan reference number is provided as 657890236758409 and monthly installment is $ 12.50K" & @CRLF & _ "you have received the loan reimbursement of 2.9 million dollars" & @CRLF & _ "this month loan amount is 54,98.45K and transaction no is a72h6j98" & @CRLF & _ "this client transaction num: A7287509j is invalid but unlock key is 57zod-8ftf9-p0fu3 is valid" & @CRLF & _ "The party id - 12345678900 is actually a customer whose loan number is 12345678" & @CRLF & _ "customer: 09876543211 and loan num 123456789" & @CRLF & _ "The credit scores are: fico 123 and Port Number 64438" & @CRLF & _ "credit score is 987 and unlock key: cmydh-gpgke-3xehb" & @CRLF & _ "234 678 and unlock key - dzdb9950bsi3su4" & @CRLF & _ "984 652 836 and access the drive \\Dfs.uk.ml.com\london\gtsshared\ProjectDelivery\TI" & @CRLF & _ "License key: B40ZH2PLKRHUN7RD8P7PQ6MHSMFC5HPUG2YJW-142-101-064-0E" & @CRLF & _ "License key: EDJWMHCS3SGAPPCCBFLARYZMX7ZMWRFLKM-142-100-934-AD" & @CRLF & _ "this is some kind of key I guess 490853-104214-320254-230868-710347-170533-492679-288992" & @CRLF & _ "Even this is some kind of key 090640-265034-253704-024937-145321-484748-151778-459074" & @CRLF & _ "this mail is regarding employee termination of user nbkh7h0 " & @CRLF & _ "ssh2: RSA SHA256:hKeAu/WKftYpqXHW4ReTrv3wXYbkdkdNgnEyGHkMCsSPU" & @CRLF & _ "URGENT TERMINATION: User - zk8hy5f " & @CRLF & _ "RSA key fingerprint is SHA256:N5JRToYZAAlaroppYu7R7aB06ihyqvCVrYfLxLC" & @CRLF & _ "we have received a terminatION request for user zk4gh8y" & @CRLF & _ "access key: hba1x oc6a4 fx7uq and drive link: \\nrch3000-nas03.bankofamerica.com\nrch0300_user033$\8tzkj6h\homespace" & @CRLF & _ "Security code: 690037 and Port: 6443" & @CRLF & _ "unlock key tnaxx-9hbx7-pdg33 Port 6443" & @CRLF & _ ""Traceback (most recent call last):" & @CRLF & _ " File ""/path/to/example.py"", line 4, in <module>" & @CRLF & _ " greet('Chad')" & @CRLF & _ " File ""/path/to/example.py"", line 2, in greet" & @CRLF & _ " print('Hello, ' + someon)" & @CRLF & _ "NameError: name 'someon' is not defined"" & @CRLF & _ "pbrun7.5.0-12[404]: Request rejected by pbmasterd on server1234.abcd.yyyy.com. " & @CRLF & _ "Error: "sh: pbrun: command not found"" & @CRLF & _ " http://ah-1004452-001.corp.bankofamerica.com:8080/" & @CRLF & _ "production server lmumm01spdbd1.corp.bankofamerica.com:49125 is depricated" & @CRLF & _ "tcp link is given as - tcp://ah-1005300-001.sdi.corp.bankofamerica.com:8343" & @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