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

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

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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html