Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • 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
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 single character of: a, b, c or d
    [[ab][cd]]
  • 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]
  • Character class intersection
    [\w&&[^\d]]
  • 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

Substitution
Processing...

Code Generator

Generated Code

import re regex = re.compile(r"(?m)^(\h*)maxlength:(?:\R\1(?!\h*maxlength_js_enforce:)(\h+).*)*$(?!\R\1\h)", flags=re.MULTILINE) test_str = ("uuid: e3737897-ae40-4771-8aff-33d2fe76eeee\n" "langcode: de\n" "status: true\n" "dependencies:\n" " config:\n" " - config_pages.type.chatbot\n" " - field.field.config_pages.chatbot.field_2click_solution_label\n" " - field.field.config_pages.chatbot.field_2click_solution_logo\n" " - field.field.config_pages.chatbot.field_2click_solution_popup_text\n" " - field.field.config_pages.chatbot.field_title_div\n" " - field.field.config_pages.chatbot.field_url\n" " module:\n" " - field_group\n" " - field_states_ui\n" " - file\n" " - link\n" " - link_field_tweak\n" " - maxlength\n" " - text\n" "third_party_settings:\n" " field_group:\n" " group_struktur_definitionen:\n" " children:\n" " - group_tab_settings\n" " - group__tab_policy\n" " label: 'Chatbot Einstellungen'\n" " region: content\n" " parent_name: ''\n" " weight: 1\n" " format_type: tabs\n" " format_settings:\n" " classes: ''\n" " show_empty_fields: false\n" " id: ''\n" " direction: horizontal\n" " width_breakpoint: 640\n" " group_tab_settings:\n" " children:\n" " - field_url\n" " - field_2click_solution_logo\n" " - field_title_div\n" " label: Einstellungen\n" " region: content\n" " parent_name: group_struktur_definitionen\n" " weight: 20\n" " format_type: tab\n" " format_settings:\n" " classes: ''\n" " show_empty_fields: false\n" " id: ''\n" " formatter: closed\n" " description: ''\n" " required_fields: true\n" " group__tab_policy:\n" " children:\n" " - field_2click_solution_label\n" " - field_2click_solution_popup_text\n" " label: Datenschutzhinweis\n" " region: content\n" " parent_name: group_struktur_definitionen\n" " weight: 21\n" " format_type: tab\n" " format_settings:\n" " classes: ''\n" " show_empty_fields: false\n" " id: ''\n" " formatter: closed\n" " description: ''\n" " required_fields: true\n" "id: config_pages.chatbot.default\n" "targetEntityType: config_pages\n" "bundle: chatbot\n" "mode: default\n" "content:\n" " field_2click_solution_label:\n" " type: string_textfield\n" " weight: 22\n" " region: content\n" " settings:\n" " size: 60\n" " placeholder: ''\n" " third_party_settings:\n" " field_states_ui:\n" " form:\n" " type: ''\n" " list: ''\n" " add: Hinzufügen\n" " maxlength:\n" " maxlength_js: 60\n" " maxlength_js_label: 'Inhalt auf @limit Zeichen begrenzt, verbleibend: <strong>@remaining</strong><br><br>'\n" " field_2click_solution_logo:\n" " type: file_generic\n" " weight: 22\n" " region: content\n" " settings:\n" " progress_indicator: throbber\n" " third_party_settings: { }\n" " field_2click_solution_popup_text:\n" " type: text_textarea\n" " weight: 23\n" " region: content\n" " settings:\n" " rows: 5\n" " placeholder: ''\n" " third_party_settings:\n" " field_states_ui:\n" " form:\n" " type: ''\n" " list: ''\n" " maxlength:\n" " maxlength_js: null\n" " maxlength_js_label: 'Inhalt auf @limit Zeichen begrenzt, verbleibend: <strong>@remaining</strong>'\n" " maxlength_js_enforce: true\n" " maxlength_js_truncate_html: false\n" " field_title_div:\n" " type: string_textfield\n" " weight: 23\n" " region: content\n" " settings:\n" " size: 60\n" " placeholder: ''\n" " third_party_settings: { }\n" " field_url:\n" " type: link_default\n" " weight: 21\n" " region: content\n" " settings:\n" " placeholder_url: 'URL zu einer JavaScript Datei'\n" " placeholder_title: ''\n" " third_party_settings:\n" " field_states_ui:\n" " form:\n" " type: ''\n" " list: ''\n" " add: Hinzufügen\n" " link_field_tweak:\n" " uri_part_custom_help: false\n" " uri_part_custom_help_text: ''\n" " maxlength:\n" " maxlength_js: null\n" " maxlength_js_label: 'Inhalt auf @limit Zeichen begrenzt, verbleibend: <strong>@remaining</strong>'\n" "hidden:\n" " label: true\n" " path: true\n") subst = "$0\\n$1$2maxlength_js_enforce: true" result = regex.sub(subst, test_str) if result: print(result)

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 Python, please visit: https://docs.python.org/3/library/re.html