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

/
/
gm

Test String

Substitution

Processing...

Code Generator

Generated Code

# If you'd like to omit non-matching lines from the result; add ';d' to the end of the expression. sed -E 's/(\w{2})/0x$1, /gm;t' <<< "308204BF020100300D06092A864886F70D0101010500048204A9308204A50201 000282010100A9CB5B5A9C012B67FE9184A886824843D5AFD01192B48E8D228F CFC4131A27A5B19F55507EFC72E2D9C4FB6DA86CA22310E03C5DFB54A54A1034 16160127712051DB0CDEEF32D32D50B9EFA98563AD4070A793C0621B6ED17FD5 45632788FE638A6F53E8686DECFE689E2547D9647F41FA8A5AF7368090420C0A 100B80A7876A165C537FC91047883285FA2DB31320A3A47D4009C5367C6B6B38 34D889565C7DA7D1F7B44CA90B4E45201E775F909738FD608A3D644EEE720E14 1EB917BF326CA13C2B32B43608CC83CFFC67B90FC1D6AFD28C826F4F9DE39288 188173EB0BB51C02B8FF0116411893C222875151BBA0259D6258296A480837E7 FC3F097F23C90203010001028201003339191F35AF18A42FE5408B02C12D01E1 E63F33FDF920842D680B3AD0B4743F855D570488BAAA020BC6643F89AEF41EF6 095FCCCE7493C4CB2C9B7919F2072BC3E5FC7508DE615CEB5C9C939C9D1C7833 442ACBC00D1C9A71212AE4A5D9AB3CE6577D8DC06B6132C2E6EAC249300B4021 5039EF186F2295FA41D2E35575B4E0EB7D68517F39D5A2EDDB8ACED8A7E49ADA E5F4F9A185639261B9007CDCC1F42990B0039B55112387DF17583A32F4D3712F E35C73069EE2B73AE63F73EF52B31E5EC8AD4D53D07A330D687B894877676345 092B4F6DE5C9C3C9BBAC05CC02CF5F8318EFA0E95892F25E3A804CA02E17160D 70B2BE2EB45807139E269A6B9EFC6D02818100CD86015BE7DCA8E0204D73D96A 4A4467681D87147BEF96AFCDD39536A4759AD7CF816876298D35563D2D862E52 0EC7D848C8AA53F8B85D1FDF1D3538919F0C639ADA67B3EBD3ED4C4317E674FA D627E041A37B406F04F09892B703288AA30EA60793F582CED515FC4520F1AE43 E718667262F027D7520E238194AF29FB9C056302818100D37EEF8066A10F69BB 5B97CA9977F4C9D82B7707ECE0BF54D095E392DBA2A1B941A0D90E66B14A313A 780C65F6BE63CA5F3491F20109C041C8726BC5A856F09C1E4F45BDE0CB10D9C4 E9F33FFAB92B66D4289D5CF83C2DE339BA73F7942A19556F3EF6526CF156AEA5 65CA5269042610D0CE2B9BFE1AFCD2F057F5A941D13FE302818100AA12321DB3 88CDD669E4ADF1441BA0EF5120DE1EFD500E09FCF11190DE16D3C3B25B0BEE7C 03F6171F1904E85FCF0B60D719F698F640DA0EFDBA55C831F8C36FC93CE283E8 AABEBB54E9FA32E33F44503700E98530598E1F33896E7BA5FDB8A97BABDC861A 520A976F3D0BC1813F42D9C3DE4B8D2C89225A0F68D26A936350B102818100A0 EEED362A62124565610BFF098AC305386DD294804680B0FC4BA230E4DA3AEFAA 25C824F235A3FC13BEB7C87ADA633AE1F931B911DB26A5A7EE915D857C2A78D1 8386D13695AECBD6D022DE235DF5CDB850F375841ADEDC11D87458073185B782 004A156C7AB4780EB9871BF0774CB3ECFF85259D5551DEFD2E216BDAFE6BFB02 818100BCF51782BBC9C4689771CFCAFD06654068E23D9879D0F3AC3D4A9B481B 06AFB8422E16FB96471D9340987603008BFC067B2214CEE3AFC036D01A765579 67C28DD9C5541FA0A8A5FAD7DF884B3DCE17A8BC34E7E3E2276457380C44BA79 3CD92EA71693F1B1DC31AC18F5C37CE9C8A2496297F5DEBC3313ED1F92EC0F68 652261"

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 SED, please visit: https://www.gnu.org/software/sed/manual/html_node/The-_0022s_0022-Command.html