Regular Expressions 101

Save & Share

  • Regex Version: ver. 3
  • Update Regex
    ctrl+⇧+s
  • Save new Regex
    ctrl+s
  • Add to Community Library

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

/
/

Test String

Code Generator

Generated Code

import java.util.regex.Matcher; import java.util.regex.Pattern; public class Example { public static void main(String[] args) { final String regex = "((var|const|let)\\s+)?[A-Za-z0-9_\\.\\[\\]\"\\']+\\s?=\\s+?\\{"; final String string = "acf0.data = {\"select2L10n\":{\"matches_1\":\"Es ist ein Ergebnis verf\\u00fcgbar, dr\\u00fccke die Eingabetaste um es auszuw\\u00e4hlen.\",\"matches_n\":\"Es sind %d Ergebnisse verf\\u00fcgbar, benutze die Pfeiltasten um nach oben und unten zu navigieren.\",\"matches_0\":\"Keine \\u00dcbereinstimmungen gefunden\",\"input_too_short_1\":\"Gib bitte ein oder mehr Zeichen ein\",\"input_too_short_n\":\"Gib bitte %d oder mehr Zeichen ein\",\"input_too_long_1\":\"L\\u00f6sche bitte ein Zeichen\",\"input_too_long_n\":\"L\\u00f6sche bitte %d Zeichen\",\"selection_too_long_1\":\"Du kannst nur ein Element ausw\\u00e4hlen\",\"selection_too_long_n\":\"Du kannst nur %d Elemente ausw\\u00e4hlen\",\"load_more\":\"Mehr Ergebnisse laden&hellip;\",\"searching\":\"Suchen&hellip;\",\"load_fail\":\"Laden fehlgeschlagen\"},\"google_map_api\":\"https:\\/\\/maps.googleapis.com\\/maps\\/api\\/js?key=AIzaSyDzJU4YaeA4XDHAN1BvFOZD8A2eF5lxYr0&libraries=places&ver=3&callback&language=de_DE\",\"datePickerL10n\":{\"closeText\":\"Fertig\",\"currentText\":\"Heute\",\"nextText\":\"N\\u00e4chstes\",\"prevText\":\"Vorheriges\",\"weekHeader\":\"W\",\"monthNames\":[\"Januar\",\"Februar\",\"M\\u00e4rz\",\"April\",\"Mai\",\"Juni\",\"Juli\",\"August\",\"September\",\"Oktober\",\"November\",\"Dezember\"],\"monthNamesShort\":[\"Jan\",\"Feb\",\"Mrz\",\"Apr\",\"Mai\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Okt\",\"Nov\",\"Dez\"],\"dayNames\":[\"Sonntag\",\"Montag\",\"Dienstag\",\"Mittwoch\",\"Donnerstag\",\"Freitag\",\"Samstag\"],\"dayNamesMin\":[\"S\",\"M\",\"D\",\"M\",\"D\",\"F\",\"S\"],\"dayNamesShort\":[\"So\",\"Mo\",\"Di\",\"Mi\",\"Do\",\"Fr\",\"Sa\"]},\"dateTimePickerL10n\":{\"timeOnlyTitle\":\"Zeit ausw\\u00e4hlen\",\"timeText\":\"Zeit\",\"hourText\":\"Stunde\",\"minuteText\":\"Minute\",\"secondText\":\"Sekunde\",\"millisecText\":\"Millisekunde\",\"microsecText\":\"Mikrosekunde\",\"timezoneText\":\"Zeitzone\",\"currentText\":\"Jetzt\",\"closeText\":\"Fertig\",\"selectText\":\"Ausw\\u00e4hlen\",\"amNames\":[\"Vorm.\",\"Vorm.\"],\"pmNames\":[\"Nachm.\",\"Nachm.\"]},\"colorPickerL10n\":{\"hex_string\":\"Hex String\",\"rgba_string\":\"RGBA String\"},\"mimeTypeIcon\":\"https:\\/\\/wptest.photoclub-reutlingen.de\\/wp-includes\\/images\\/media\\/default.png\",\"mimeTypes\":{\"jpg|jpeg|jpe\":\"image\\/jpeg\",\"gif\":\"image\\/gif\",\"png\":\"image\\/png\",\"bmp\":\"image\\/bmp\",\"tiff|tif\":\"image\\/tiff\",\"webp\":\"image\\/webp\",\"ico\":\"image\\/x-icon\",\"heic\":\"image\\/heic\",\"asf|asx\":\"video\\/x-ms-asf\",\"wmv\":\"video\\/x-ms-wmv\",\"wmx\":\"video\\/x-ms-wmx\",\"wm\":\"video\\/x-ms-wm\",\"avi\":\"video\\/avi\",\"divx\":\"video\\/divx\",\"flv\":\"video\\/x-flv\",\"mov|qt\":\"video\\/quicktime\",\"mpeg|mpg|mpe\":\"video\\/mpeg\",\"mp4|m4v\":\"video\\/mp4\",\"ogv\":\"video\\/ogg\",\"webm\":\"video\\/webm\",\"mkv\":\"video\\/x-matroska\",\"3gp|3gpp\":\"video\\/3gpp\",\"3g2|3gp2\":\"video\\/3gpp2\",\"txt|asc|c|cc|h|srt\":\"text\\/plain\",\"csv\":\"text\\/csv\",\"tsv\":\"text\\/tab-separated-values\",\"ics\":\"text\\/calendar\",\"rtx\":\"text\\/richtext\",\"css\":\"text\\/css\",\"vtt\":\"text\\/vtt\",\"dfxp\":\"application\\/ttaf+xml\",\"mp3|m4a|m4b\":\"audio\\/mpeg\",\"aac\":\"audio\\/aac\",\"ra|ram\":\"audio\\/x-realaudio\",\"wav\":\"audio\\/wav\",\"ogg|oga\":\"audio\\/ogg\",\"flac\":\"audio\\/flac\",\"mid|midi\":\"audio\\/midi\",\"wma\":\"audio\\/x-ms-wma\",\"wax\":\"audio\\/x-ms-wax\",\"mka\":\"audio\\/x-matroska\",\"rtf\":\"application\\/rtf\",\"pdf\":\"application\\/pdf\",\"class\":\"application\\/java\",\"tar\":\"application\\/x-tar\",\"zip\":\"application\\/zip\",\"gz|gzip\":\"application\\/x-gzip\",\"rar\":\"application\\/rar\",\"7z\":\"application\\/x-7z-compressed\",\"psd\":\"application\\/octet-stream\",\"xcf\":\"application\\/octet-stream\",\"doc\":\"application\\/msword\",\"pot|pps|ppt\":\"application\\/vnd.ms-powerpoint\",\"wri\":\"application\\/vnd.ms-write\",\"xla|xls|xlt|xlw\":\"application\\/vnd.ms-excel\",\"mdb\":\"application\\/vnd.ms-access\",\"mpp\":\"application\\/vnd.ms-project\",\"docx\":\"application\\/vnd.openxmlformats-officedocument.wordprocessingml.document\",\"docm\":\"application\\/vnd.ms-word.document.macroEnabled.12\",\"dotx\":\"application\\/vnd.openxmlformats-officedocument.wordprocessingml.template\",\"dotm\":\"application\\/vnd.ms-word.template.macroEnabled.12\",\"xlsx\":\"application\\/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\"xlsm\":\"application\\/vnd.ms-excel.sheet.macroEnabled.12\",\"xlsb\":\"application\\/vnd.ms-excel.sheet.binary.macroEnabled.12\",\"xltx\":\"application\\/vnd.openxmlformats-officedocument.spreadsheetml.template\",\"xltm\":\"application\\/vnd.ms-excel.template.macroEnabled.12\",\"xlam\":\"application\\/vnd.ms-excel.addin.macroEnabled.12\",\"pptx\":\"application\\/vnd.openxmlformats-officedocument.presentationml.presentation\",\"pptm\":\"application\\/vnd.ms-powerpoint.presentation.macroEnabled.12\",\"ppsx\":\"application\\/vnd.openxmlformats-officedocument.presentationml.slideshow\",\"ppsm\":\"application\\/vnd.ms-powerpoint.slideshow.macroEnabled.12\",\"potx\":\"application\\/vnd.openxmlformats-officedocument.presentationml.template\",\"potm\":\"application\\/vnd.ms-powerpoint.template.macroEnabled.12\",\"ppam\":\"application\\/vnd.ms-powerpoint.addin.macroEnabled.12\",\"sldx\":\"application\\/vnd.openxmlformats-officedocument.presentationml.slide\",\"sldm\":\"application\\/vnd.ms-powerpoint.slide.macroEnabled.12\",\"onetoc|onetoc2|onetmp|onepkg\":\"application\\/onenote\",\"oxps\":\"application\\/oxps\",\"xps\":\"application\\/vnd.ms-xpsdocument\",\"odt\":\"application\\/vnd.oasis.opendocument.text\",\"odp\":\"application\\/vnd.oasis.opendocument.presentation\",\"ods\":\"application\\/vnd.oasis.opendocument.spreadsheet\",\"odg\":\"application\\/vnd.oasis.opendocument.graphics\",\"odc\":\"application\\/vnd.oasis.opendocument.chart\",\"odb\":\"application\\/vnd.oasis.opendocument.database\",\"odf\":\"application\\/vnd.oasis.opendocument.formula\",\"wp|wpd\":\"application\\/wordperfect\",\"key\":\"application\\/vnd.apple.keynote\",\"numbers\":\"application\\/vnd.apple.numbers\",\"pages\":\"application\\/vnd.apple.pages\"},\"toolbars\":{\"full\":{\"1\":\"formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,wp_more,spellchecker,fullscreen,wp_adv\",\"2\":\"strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help\",\"3\":\"\",\"4\":\"\"},\"basic\":{\"1\":\"bold,italic,underline,blockquote,strikethrough,bullist,numlist,alignleft,aligncenter,alignright,undo,redo,link,fullscreen\"}},\"admin_url\":\"https:\\/\\/wptest.photoclub-reutlingen.de\\/wp-admin\\/\",\"ajaxurl\":\"https:\\/\\/wptest.photoclub-reutlingen.de\\/wp-admin\\/admin-ajax.php\",\"nonce\":\"6f1ca57d8e\",\"acf_version\":\"5.10.1\",\"wp_version\":\"5.8.1\",\"browser\":\"chrome\",\"locale\":\"de_DE\",\"rtl\":false,\"screen\":null,\"post_id\":null,\"validation\":null,\"editor\":\"classic\"};\n"; final Pattern pattern = Pattern.compile(regex); final Matcher matcher = pattern.matcher(string); if (matcher.find()) { System.out.println("Full match: " + matcher.group(0)); for (int i = 1; i <= matcher.groupCount(); i++) { System.out.println("Group " + i + ": " + matcher.group(i)); } } } }

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 Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html