Regular Expressions 101

Save & Manage Regex

  • Current Version: 17
  • 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

Substitution
Processing...

Code Generator

Generated Code

$re = '/(.*?(cardNumber|card.number|number|cvc|cvv|cardVerificationCode|card_Verification_Code|cardVerificationValue|card_Verification_Value|expireMonth|expireYear|x-api-key|apiKey)[\\\\\\\\\"]*:[ \\\\[\n\\\\\\\\\"\\\\]]*)[a-zA-Z0-9$&+,:;=?@#|\'<>.^*()%!-]+(.*?)/'; $str = '{"cardNumber": "34be18a5-f710-45ba-9b4d-0c13c9b07c7e", "http_method": "POST", "url": "https://api.qabakuun.cloud/ratedockAPI/RDK259/booking", "headers": {"User-Agent": "python-requests/2.28.1", "Accept-Encoding": "gzip, deflate", "Accept": "application/json", "Connection": "keep-alive", "Content-Type": "application/json", "Content-Length": "1791"}, "body": {"username": "rhcp@secretescapes.com", "password": "BbiqzYuP", "partnerId": "RDK259", "partnerName": "SecretEscapes", "action": "getBooking", "hotelReservation": [{"hotelCode": "TESTRATEDOCKHOTEL", "hotelName": "Test Ratedock Hotel", "resStatus": "New", "checkIn": "2022-10-10", "checkOut": "2022-10-12", "paymentMethod": "BANK", "rateType": "BAR", "currencyCode": "GBP", "totalAdult": "1", "totalChild": "0", "child_ages": [], "totalBaby": "0", "baby_ages": [], "roomStays": [{"roomTypeId": "TESTRATEDOCKROOMTYPE", "roomName": "Test Ratedock Room Type", "roomType": "Daily Room", "numberOfUnits": "1", "adultCount": "1", "childCount": "0", "child_ages": [], "babyCount": "0", "commission": "0.00", "roomIndex": "1", "ResGuestRPH": "1", "bookingPerDayPrices": [{"dateYmd": "2022-10-10", "price": "184.90", "ratePlanId": "TESTRATEDOCKRATEPLAN", "cancelPolicy": ""}, {"dateYmd": "2022-10-11", "price": "159.60", "ratePlanId": "TESTRATEDOCKRATEPLAN", "cancelPolicy": ""}], "total": {"amountAfterTaxes": "344.50", "amountBeforeTaxes": "344.50"}, "roomIncServices": []}], "guestDetails": [{"ResGuestRPH": "1", "firstName": "(redacted)", "lastName": "(redacted)", "middleName": "", "email": "test+uk@secretescapes.com", "phone": "123123123", "address": "", "country": ""}], "Comment": {"Text": ""}, "paymentCard": {"cardHolderName": "", "cardType": "", "cardCategory": "", "cardNumber": "", "ExpiryMonth": "", "ExpiryYear": "", "StartDayMonth": "", "StartDayYear": "", "IssueNum": "", "seriesCode": "", "vccCurrencyCode": "", "vccBalance": "", "vccDeactivationDate": "", "vccActivationDate": ""}, "totalCharge": [{"taxDetails": {"typeTax": "", "includes": "", "taxPrice": "", "taxDetails": ""}, "priceDetails": [{"rateType": "BAR", "amountAfterTaxes": "344.50", "amountBeforeTaxes": "344.50"}]}]}]}}'; $subst = "$1***$2"; $result = preg_replace($re, $subst, $str, 1); 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