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

/
/
g

Test String

Code Generator

Generated Code

const regex = /[a-zA-Z0-9\/\\\_\!\#\$\%\&\'\(\)\+\,\.\:\=\@\[\]\^\-\`\{\}~\s]*/g; // Alternative syntax using RegExp constructor // const regex = new RegExp('[a-zA-Z0-9\\\/\\\\\\_\\!\\#\\$\\%\\&\\\'\\(\\)\\+\\,\\.\\:\\=\\@\\[\\]\\^\\-\\`\\{\\}~\\s]*', 'g') const str = `<p><font size="3"> </font></p><p style="margin: 0in 0in 10pt;"><font face="Calibri" size="3">&nbsp;</font></p><p><font size="3"> </font></p><p style="margin: 0in 0in 10pt;"><a href="file:///C:/Users/admin/Documents/Anirudh/WFW_Cred.txt"><font color="#0000ff" face="Calibri" size="3">C:\\Users\\admin\\Documents\\Anirudh\\WFW_Cred.txt</font></a></p><p><font size="3"> </font></p><p style="margin: 0in 0in 10pt;"><a href="file:///C:/Users/admin/Documents/Anirudh/AST_Cred.txt"><font color="#0000ff" face="Calibri" size="3">AST_Cred.txt</font></a></p><p><font size="3"> </font></p><p style="margin: 0in 0in 10pt;"><a href="file:///C:/Users/admin/Documents/Anirudh/Todolist.txt"><font color="#0000ff" face="Calibri" size="3">Todolist.txt</font></a></p><p><font size="3"> </font></p><p style="margin: 0in 0in 10pt;"><a href="https://cdn.at.atwola.com/_media/uac/msn.html"><font color="#0000ff" face="Calibri" size="3">https://cdn.at.atwola.com/_media/uac/msn.html</font></a></p><p><font size="3"> </font></p><p style="margin: 0in 0in 10pt;"><a href="file:///C:/Users/admin/Documents/Anirudh/Temp.txt"><font color="#0000ff" face="Calibri" size="3">Temp.txt</font></a></p><p><font size="3"> </font></p><p style="margin: 0in 0in 10pt;"><a href="file:///C:/Users/admin/Documents/Anirudh/ABC.doc"><font color="#0000ff" face="Calibri" size="3">ABC.doc</font></a></p><p><font size="3"> </font></p><p style="margin: 0in 0in 10pt;"><a href="http://localhost:9080/manager/main.jsp"><font color="#0000ff" face="Calibri" size="3">The Manager gateway</font></a></p><p><font size="3"> </font></p><p style="margin: 0in 0in 10pt;"><a href="res://C:\\Program%20Files\\Internet%20Explorer\\F12Resources.dll/23/emulation/emulation.html"><font color="#0000ff" face="Calibri" size="3">Emulation</font></a></p><p><font size="3"> </font></p><p style="margin: 0in 0in 10pt;"><a href="res://C:\\Program%20Files\\Internet%20Explorer\\F12Resources.dll/23/perftools/memory/memoryAnalyzer.html"><font color="#0000ff" face="Calibri" size="3">Memory</font></a></p><p><font size="3"> </font></p><p style="margin: 0in 0in 10pt; tab-stops: 170.3pt;"><a href="http://localhost:9080/manager/1ppaauthor/"><font color="#0000ff" face="Calibri" size="3">BCI - Author</font></a><span style="mso-tab-count: 1;"><font face="Calibri" size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></p><p><font size="3"> </font></p><p style="margin: 0in 0in 10pt;"><a href="file:///C:/Users/admin/Documents/Anirudh/ABC.doc"><font color="#0000ff" face="Calibri" size="3">ABC.doc</font></a></p><p><font size="3"> </font></p><p style="margin: 0in 0in 10pt;"><a href="res://C:\\Program%20Files\\Internet%20Explorer\\F12Resources.dll/23/console/console.html"><font color="#0000ff" face="Calibri" size="3">Console</font></a></p><p><font size="3"> </font></p><p style="margin: 0in 0in 10pt;"><a href="file:///C:/Users/admin/Documents/Anirudh/WFA_Cred.txt"><font color="#0000ff" face="Calibri" size="3">WFA_Cred.txt</font></a></p><p><font size="3"> </font></p><p style="margin: 0in 0in 10pt;"><font face="Calibri" size="3">&nbsp;</font></p><p><font size="3"> </font></p><p style="margin: 0in 0in 10pt;"><font size="3"><img width="103" height="66" src="data:image/png;base64,R0lGODlhZwBCAHcAMSH+GlNvZnR3YXJlOiBNaWNyb3NvZnQgT2ZmaWNlACH5BAEAAAAALBYAAgA5ACwAhwAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBmAABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmAD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YOAIpJguU46ChRIkO0rw6JyIZrBrHkMHlbGPIDFEz7KhIde+CDWYd4NiqSwwuVTca3Xh7oytFjUHy/34+sEGrv63GdMERo8vivRvB2+ZIqzl5ggeqY5Nalgv7MRoJEpkigQ1CoCK5YfPFePc1cEAX8I0WYSId3UYLNvU5d59ALARgQgCDCNKKiD259dCBBn6BYGkLbkhQADAOspeMIyYiIkcU0ofhUYRo6OJAOVp4lCIXJvjdF4GxyOCPAHRHIENPYkPgF9wpeBRXPTJ5kEa3aVQfl9hgMaQrXxClUYtaCtRdjlViQyGSIWHjBVdcgeEjk5CBdOAXiVBJpZgJ0ZIkUWimuR2R87mp4IV+0umKnWkKhBBItX13ZphHIVQmULQUqqWFDz0U0iBefFHqqaaWWeedP+ZpZGkJttTCFadwecqkILQUmeuVusKFla9YQRopQo8NqOKxiiB7rBlfgGHrj5TNMEML07ZArbXXWltttqxG6u234IYr7rgVwUjXjyWcW5e55ZobwGbsbraCuj92aJhF7uar7778xisQu/0CbO6HMHZYMIwvIgDAweneC0C6BZlr8EgBKDxxhwL8q+/CCAcc78YvdpzvQP6mK4C5Cs87MccUq6xUhxbTO2/G9gKwsr8Cv7txwCyznPPO+3IYAM1D21z0vDCe3LDEGkvsNNEHw4hAzvAiTO5NK4cbEAA7" border="0" v:shapes="_x0000_i1025"><img width="103" height="66" src="data:image/png;base64,R0lGODlhZwBCAHcAMSH+GlNvZnR3YXJlOiBNaWNyb3NvZnQgT2ZmaWNlACH5BAEAAAAALAsABQBPACkAhgAAAAAAAAoJCQkHCAgHBwsKCgkICQ0KCAMDCAsLDQMAAwgKDQ0LCgQABAoLDQMAAAwKCwAABAoKCAsKCAsGAwMDAwQIDQoEAwoEBAoIBAMGCw0IBAgEAAAAAwgICAADCA0LCwgDAAMGCAQAAAgKCwgECAsLCgQDCAoEAAAECgMABAoLCwgDAwMECggDBAoLCgsGBAgKCgoGAwsIBAQAAwQGCwMEBDY1NTg3Nzs6Ojc2N7+/v6ysrri4vbm5ubKysq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yN8GQKp64AUVqLdBBRUu2eSTgiKpQaCfmkDDm4OSGuaWD9YAAAhurumespG+8Ot5ZQpCgahQPljfhmqCt6QNwY7HKo0sCgteilmOYB+G0aIQgI5X+qnuo2Jt0Gl30airIZp9BQIAOw==" border="0" v:shapes="_x0000_i1026"><img width="103" height="66" src="data:image/png;base64,R0lGODlhZwBCAHcAMSH+GlNvZnR3YXJlOiBNaWNyb3NvZnQgT2ZmaWNlACH5BAEAAAAALAEABQBkADYAhgAAAAAAAAoJCQkHCAgHBwsKCgkICQ0IBAQIDQ0LCwgDAAwKCwAAAwgKDQsGAwAECg0KCAMAAAMABAoKCAoLDQ0LCgQAAAsGBAAABAoEAAADCAsLDQQAAwMDCAgDAwsKCAMAAwMGCwgECAoEBAQABAQDCAsLCggDBAoLCwQGCwsIBAgKCwQECggKCgoEAwMGCAoLCjY1NTg3Nzs6Ojc2N7+/v6ysrri4vbm5ubKysqurq6mpqa+vr7W1tbi4uL+/xNbW1szMzMHBw8fHx9zc3Nra3cPDw83NzcbGxs7OzsjW4PPz9v7+/+np7PDw8/39/fz8/P39/Orq6vDv8uTk5P7+/v7+/fz8+/r6+uvr6/v7+/X19fT09OPj4/v7+uTr8Pr6+fn5+fn5+Pj4+Pj49/f39/f39gECAwECAwECAwECAwECAwECAwECAwECAwECAwECAwECAwECAwECAwECAwECAwECAwECAwECAwECAwECAwECAwECAwECAwECAwECAwf/gACCg4SFhoeIg0CLS4tAjYyLQUJDiZaXmJmamkBMTT9OT5+ho1BENTYLm6usraudNwBFT7FFUbVQUkZDMaquv8C/nZ9Toj9TUMRQUEdUSDK+wdLTiUBVVVZP2lHL3VdXSVhZQzPR1OfU1trr291QWkhbXF04NObo+K5A7Ovc7lo5dOzYwaOHgHv5EmZSx86fNy1evABJUsPHAIQKMyIC8kWJx48gQ36UQqCAxpOWGDpc9k0LRCwwwYCJUhKlTUMcReoM+aXmzZ8Acu4c2tMk0JvWvF1x6TIiFplhwogRA8XnUZRCh+osetVm0pZNncKMOnVqVaNdNWbVytNqWoVA/6wwhegF5lOZZceMIXPF7dt8a9l+5PoX7hO6dWNClbqXjOO+aAvjCyxYCWHJk58kvguG7FTHoMto8Yt5GmXBl0une6K4s9S8jsuUMWNmdGTV0k6zTY07GBCZrsuK0RubtnHbvaktMECgufPn0J8bwJi81YIC2LNr366devXv4MOLH7/qAIJ8CRQEYNCAkIMA8B8MghAB/vr2lyBImLC/PwX9FAxSgQX2nUfIBQ2YN4iCAAwYAAYBAlhIBvINksF9gzgg3wEabCBIBRy0l56BEHTgYQIe4GdJiR900GKLG5ToIQAQgIBfeiEMkoAIG4wQIAAXwofAAfJlkGMGBi4Ygv8DOdJoIpEfhgjAiB+S8COSgsg4ZYqYVFCCCV+GGaOJU55AwXsPomAmkPYJSSSDUBqp5XwmotiejEwKwuGMedIowZUkkmknjTYSemehiGgJQQoAJmCmAwaat6ieGqhgYHoPUoDlfIiC2N4BAYRgZ58AQAmAhgt26OSJXNZ46KuJeOnhASHI6CgFDCLI4KnxFVKiCQRCiAiRNa7waJOrGumrjVoO+ousNDL65626thlAhaUioKwgdsaZ5ITn0dchqaaiSqmHzXI5TQVWBgmfqhWwsCOfQ2qLLJTeImKuAxDuKUifEgIZKKvtDXiewQ1a8K2vZJYqrCGSpjBffdfqyKW1g6oegmmoBzDQgpRUNmilIJume+effkaIsiYOZorJrueg6m+DICsw8JafVmiqqRnBTA2m7LlnH7b02Re0C/ghLYjS5DXt9NNQizcnwzNG/cvUhGBt9Sobv2BBjsWqF+rWrigqAQqtNkw2K3O+16TWa2cyJ6hvq92bhBLiOKUCOertN98pB84uDFIGnBzeKHtKc8FSKq54wBd6fd4Bwl6I7Hg766y5ntjGnQik/xoI+qmiL9xVIAA7" border="0" v:shapes="_x0000_i1027"><img width="103" height="66" src="data:image/png;base64,R0lGODlhZwBCAHcAMSH+GlNvZnR3YXJlOiBNaWNyb3NvZnQgT2ZmaWNlACH5BAEAAAAALAAAAgBkACoAhwAAAAAAAAAAMwAAZgAAmQA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DJs0aIz1eqciyp0+NhAa5SjTUldBBipAidTGSKLYWJ39KnToQjKuROWnkxEaLFlSLVMOyBKNI5NWPrbC5UqTgo9Ghra66ooUgqti7G7+4+sI3SyJsWmvIrDFIK7ayXIUSTaQIKt7HGMEMCqoIC7YsNFopmvmFUFu1tEgmuuJlBpYWWBBAXn1QL7ZBlju7MFojAbYvTA+7utqQ8cQZrINX9Zjly6AvNWgcTyDIlWe3RxUZDx23hXDhNcp+wTIouWAaLdLi//6YVKl0kIOsX2ct+TKh5K3AJLfcipBttdGRynUFdj3kLGXRlBk2ySFw1hefGafgcVxhkwhw/v3nkQLKkVQDAg7hdx9JIF1FXWMRQkYDYiGFFtpVCGLVYGjphfhYcUlJR0hnnWUxiI0JGJWUjvqppYhqLt5FQ3I0FKmAC0cqoKQCCWwIUmhu0UIIhEFC5lFcRB3Fo3QxfqHIVZqpV+Vjf6mI1YmgfSHmmHcJwtVb+XUpXSJeprVWf2yKVeZHUDboVoNznegKGFTmGZabu8XpJVJeNupUmIbe5ZGfK1Y616W0zAXGmpFKhahaoMoFaqPHKdJKpj92GpZTaJ7YFWiCXv86aKGq+uSmnRyCCSqup86VyKa1TjWIq3Jlaiymsu4GbLA/uZmlnI1yGS1MYODJ7EqwXTHDDC10y6233bbwrbjh0nrtueimq+667LZ77knWGhTAvPSi9FO980ZIL0L7ZlRCAPGyNK9F/wYMGcD2yguwRvviiy8ADtc7UL8RoxQxxBVbnLHDBG2scb/wAnCSAAWtgDCQDQtgb8gYp9yvyRbBHAAC9Ba88Ekmq2ZzvgONLPLJANhMcsf5UnxxyxK3LNDDDyvtccVI87x00RI3PVDBQS+MtdBTJ3z1whCrTHUAKgvk80kD04s22D+TPDLZXm+NsNtqF9Tw2FF3rfDHdxstzXfGE4/d9+B/FxQyy/iunfa8Zf+c9Nox00tzvfDCLXO9MP9MMNyCI1x1vQEBADs=" border="0" v:shapes="_x0000_i1028"></font></p><p><font size="3"> </font></p>`; // Reset `lastIndex` if this regex is defined globally // regex.lastIndex = 0; let m; while ((m = regex.exec(str)) !== null) { // This is necessary to avoid infinite loops with zero-width matches if (m.index === regex.lastIndex) { regex.lastIndex++; } // The result can be accessed through the `m`-variable. m.forEach((match, groupIndex) => { console.log(`Found match, group ${groupIndex}: ${match}`); }); }

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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions