Regular Expressions 101

Save & Manage Regex

  • Current Version: 2
  • 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

use strict; my $str = '0~IPAD100KB|24~435712B711190F0B|1~11|2~|3~664518E36BB71C066EA01C203B8376A267551B8B686DBC9C03D783C7CC4798C294CA460F0D136F4A|4~|5~B8F4C16E57C4484493822A8165081A1CB2285450187B1550841A7A67A92F0BA4F2138C5E786D88D0D338656DDD80275108173461F447F625|6~|7~;4018490000001482=16040000000000000000?|8~|9~00000000|10~010001|11~95006700000060200243|12~00002200| 0~IPAD100KB|24~|1~10|2~8C5996D67CAEB2A25BC78F8801EFE7E2C0BCAA4F9E577F0D|3~D2BADAAE059905223BB23BBB0D6667A957FB2D2E116E1216C89F81A5698DD65A70D5C4DD3C4E0EB8|4~|5~377C233B970F0BB490A8F5C659BCC50F9C00F1C054827C9B53DF5D81CB90F1BF30FDEAB272452BC114687EDD133FEB141B334007C6FB19E0|6~%FCC TESTCARD 01 JPY?|7~;4907155085762001=15121011143833089?|8~|9~00000000|10~000001|11~95006700000060200244|12~00002200| 0~IPAD100KB|24~435712B711190F0B|1~11|2~A068E883FE8C20072CD646F1A6B4D5DAA89D4E2615D127FFB22EAED39974A97B221230EDA4C088497E5E6FA8336E327B148F2B3866B62079CAA733D9D56F2A8D053F726A9DBDA4E4|3~3B75F2687EC6305A5624CA16A84EF598364F560AAD30B6F315B6E31BF9C8EE9AE7D2C33C5BCC7D48|4~|5~1D7AD846DB71E44FCBCD954163BBCC5B2949BA05FEF9939F150D70684F545800C69D66E73B83E5D54CF107A55548DB0F5F22EFDD15811A16|6~%B4418610000008916^VISA ACQUIRER TEST CARD 01^12090000000000000000000?|7~;4418610000008916=12090000000000000000?|8~|9~00000000|10~000001|11~95006700000060200245|12~00002200| 0~IPAD100KB|24~435712B711190F0B|1~11|2~|3~33979CEC8F28F7325067DAF81DC054968B2963F83D2BDBEF11E7F6B9F2F2F4B0613865D5B09128D6|4~|5~FB24399EEAB51A6837C73EE4129C0E43740CDDF815E4135C3C3FCCFC4F5674BEC374880F5C213D011D1F6732A92579E76508D20075D4C363|6~|7~;4761730001000010=10120000000000000?|8~|9~00000000|10~010001|11~95006700000060200246|12~00002200| 0~IPAD100KB|24~435712B711190F0B|1~10|2~848E357AE5DCB11D22D5A08E95394B63209C11F9D902698AA94034AA525DDEFC|3~7EE238D9168975BC9F73E7E2BE72AE4E64A885E5DE744DF6325A4BFAEC570595E5BE74B58AA841CA|4~|5~F45DFCBBCCDC9680C0BD8520C8715694AABC4C5838E2AC4AA3B5DEFD8C9CD49053B124F913F84CC5349B9BE3C7A26A551A0CA701FF95B4E3|6~%CARD 07 MASTERCARD 08/12 120?|7~;5583449999803805=08121207890123456789?|8~|9~00000000|10~000001|11~95006700000060200247|12~00002200| 0~IPAD100KB|24~435712B711190F0B|1~11|2~|3~FA26247326CF66792B971E52D7E1806568C838AEB4983C002CA90196B8723AE46EE9986F0630B55C|4~|5~4AA37A2CCFDE878550C83C80A6348D836666D1ED1FB6EB0A361FF8E8300A185E677A3A01F80811D1FB51749DC63B310063DB4839B5C94825|6~|7~;5240130000000004=16120000000000000000?|8~|9~00000000|10~010001|11~95006700000060200248|12~00002200| '; my $regex = qr/6~%(.*?\^(.*?)\^.*?|.*?)\?/p; if ( $str =~ /$regex/g ) { print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n"; # print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n"; # print "Capture Group 2 is $2 ... and so on\n"; } # ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p' # Named capture groups can be called via $+{name}

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 Perl, please visit: http://perldoc.perl.org/perlre.html