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

Code Generator

Generated Code

$re = '/(?<=\"stars\"\:)\d+/m'; $str = '<script type="application/json" data-initial-state="review-info"> {"socialShareUrl":"https://fr.trustpilot.com/reviews/5e064162c845450914acd7d8","businessUnitId":"5a79a6af2a14f20001dce8d9","businessUnitDisplayName":"Qonto","consumerId":"58e77f560000ff000a8aaf52","consumerName":"Web Biz","reviewId":"5e064162c845450914acd7d8","stars":5} </script> <aside class="review__consumer-information"> <a href="/users/58e77f560000ff000a8aaf52" class="consumer-information" data-track-link="{\'target\': \'Consumer profile\', \'name\': \'consumer-info\'}"> <div class="consumer-information__picture"><div><img alt="Web Biz" src="https://user-images.trustpilot.com/58e77f560000ff000a8aaf52/73x73.png" class="consumer-information__picture"></div></div> <div class="consumer-information__details"> <div class="consumer-information__name" v-pre=""> Web Biz </div> <div class="consumer-information__data"> <div class="consumer-information__review-count"> <svg class="consumer-information__review-icon"><use xlink:href="#icon_pencil"></use></svg> <span class="">2 avis</span> </div> </div> </div> </a> </aside> <section class="review__content"> <div class="review-content"> <div class="review-content__header" v-pre=""> <div class="review-content-header"> <div class="star-rating star-rating--medium"> <img src="//cdn.trustpilot.net/brand-assets/4.1.0/stars/stars-5.svg" alt="5 étoiles : excellent" class=""> </div> <div class="review-content-header__dates"> <script type="application/json" data-initial-state="review-dates"> {"publishedDate":"2019-12-27T17:37:38Z","updatedDate":null,"reportedDate":null} </script> <div class="v-popover"><span aria-describedby="popover_39ayy7ms4m" class="trigger" style="display: inline-block;"><time datetime="2019-12-27T17:37:38.000Z" title="vendredi 27 décembre 2019 à 18:37:38" class="review-date--tooltip-target">Il y a un jour</time> <div class="tooltip-container-1"></div> <!----></span> </div> </div> <div class="review-content-header__review-verified"> <script type="application/json" data-initial-state="review-verified"> {"businessUnitDisplayName":"Qonto","consumerName":"Web Biz","informationRequestStatus":"none","isVerified":true,"verificationSource":"invitation"} </script> <div class="review-verified"><div class="v-popover"><span aria-describedby="popover_2qraarad2d" class="trigger" style="display: inline-block;"><div class="review-verified-tooltip-trigger"><svg class="icon review-verified__icon"><use xlink:href="#claimed_16"></use></svg> Commande vérifiée </div> </span> </div></div> </div> </div> </div> <div class="review-content__body" v-pre=""> <h2 class="review-content__title"> <a class="link link--large link--dark" href="/reviews/5e064162c845450914acd7d8" data-track-link="{\'target\': \'Single review\', \'name\': \'review-title\'}">Une néo-banque à la page</a> </h2> <p class="review-content__text"> J\'utilise mon compte pro depuis un logiciel via les API et j\'en suis content. </p> </div> </div> </section> <div class="review__actions"> <div class="review-actions"> <div class="review-actions__main"> <div class="review-action brand-find-useful"><div class="v-popover"><span aria-describedby="popover_fduf3oid65" class="trigger" style="display: inline-block;"><div><button role="button" tabindex="0" class="button button--subtle button--subtle-label-below brand-find-useful__button"><svg class="icon icon-thumbs-up"><use xlink:href="#icon_thumbs-up"></use></svg> <span>Utile</span> <!----></button> <div></div></div> <!----></span> </div></div> <div class="brand-share-button-wrapper"><div class="v-popover"><span aria-describedby="popover_8265ojkqp0" class="trigger" style="display: inline-block;"><div><button class="button button--subtle brand-share-button"><svg class="icon icon-share"><use xlink:href="#icon_share"></use></svg> <span class="">Partager</span></button> <div id="share-button-tooltip-container-1"></div></div> </span> </div></div> <a href="https://businessapp.b2b.trustpilot.com/#/reviews/5e064162c845450914acd7d8" rel="nofollow" target="_blank" class="button button--subtle button--subtle-label-below" title="Réponse" style="display: none" data-track-link="{ \'name\': \'reply-as-company\', \'target\': \'Business App\', \'legacyName\': \'ReplyAsCompany\' }" data-reply-as-company-button=""> <svg class="icon"> <use xlink:href="#icon_reply"></use> </svg> <span>Répondre</span> </a> </div> <div class="review-actions__notify-wrapper"> <button type="button" class="button button--subtle button--subtle-label-below" data-track-button="{ \'name\': \'notify-compliance\', \'legacyName\': \'ReportNotification Click\' }"><svg class="icon icon-flag--outline"><use xlink:href="#icon_flag_outline"></use></svg></button> </div> </div> </div> <div class="reporting"></div>'; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); // Print the entire match result var_dump($matches);

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