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
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

Substitution
Processing...

Code Generator

Generated Code

$re = '/(\*\h*\[(?:x| )\])\h*(\w*)/'; $str = '* [x] homepage_url * [x] description_good * [x] interact * [x] contribution * [x] contribution_requirements * [x] floss_license * [x] floss_license_osi * [x] license_location * [x] documentation_basics * [x] documentation_interface * [x] sites_https * [x] discussion * [x] english * [x] repo_public * [x] repo_track * [x] repo_interim * [x] repo_distributed * [x] version_unique * [x] version_semver * [x] version_tags * [x] release_notes * [ ] release_notes_vulns (@marmarek: Are QSBs always mentioned in release notes?) * [x] report_process * [x] report_tracker * [x] report_responses * [x] enhancement_responses * [x] report_archive * [x] vulnerability_report_process * [x] vulnerability_report_private * [x] build * [ ] build_common_tools (@marmarek: Does `qubes-builder` use "common tools"?) * [x] build_floss_tools * [x] test * [ ] test_invocation (@marmarek: Please fill in all "test" and "warning" criteria met.) * [ ] test_most * [ ] test_continuous_integration * [ ] test_policy * [ ] tests_are_added * [ ] tests_documented_added * [ ] warnings * [ ] warnings_fixed * [ ] warnings_strict * [x] know_secure_design * [x] know_common_errors * [x] crypto_published * [x] crypto_call * [x] crypto_floss * [x] crypto_keylength * [x] crypto_working * [x] crypto_weaknesses (arguably `qvm-backup` still passes despite #971) * [x] crypto_pfs * [x] crypto_password_storage * [x] crypto_random * [x] delivery_mitm * [x] delivery_unsigned * [x] vulnerabilities_fixed_60_days * [x] vulnerabilities_critical_fixed * [x] no_leaked_credentials * [ ] static_analysis (@marmarek: Please fill in all "analysis" criteria met.) * [ ] static_analysis_common_vulnerabilities * [ ] static_analysis_fixed * [ ] static_analysis_often * [ ] dynamic_analysis * [ ] dynamic_analysis_enable_assertions * [ ] dynamic_analysis_fixed Future Criteria ------------- * [x] installation_common (depends on how this applies to OSes) * [ ] build_reproducible * [x] crypto_used_network * [x] crypto_tls12 * [x] crypto_certificate_verification * [x] crypto_verification_private * [ ] hardened_site * [ ] hardening '; $subst = "\1 [\2](https://github.com/linuxfoundation/cii-best-practices-badge/blob/master/doc/criteria.md#\2)"; $result = preg_replace($re, $subst, $str); echo "The result of the substitution is ".$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 PHP, please visit: http://php.net/manual/en/ref.pcre.php