Regular Expressions 101

Save & Share

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

/
/
gm

Test String

Code Generator

Generated Code

$re = '/"[a-zA-Z0-9 -\/\[\]_:.\(\)@\"\-,]*",|["[a-zA-Z0-9 -\/\[\]_:.\(\)@\"\-,]*"],|},/m'; $str = '{ "slug": "submit/82276720931155/", "file_server": "go-sub3", "temp_upload": { "q95_input95": ["iShares-Fund-Changes-June-2018-vF.PDF"] }, "q44_gi_LegalEntityName": "Test 96", "q43_gi_Address": { "addr_line1": "96", "addr_line2": "", "city": "New York", "state": "NY", "postal": "10096", "country": "United States" }, "q45_gi_PhoneNumber": { "full": "(969) 696-9696" }, "q47_gi_FaxNumber": { "full": "" }, "q48_gi_CompanyWebsite": "", "q49_gi_DateOfIncorporation": { "year": "", "month": "", "day": "" }, "q50_gi_StateOfIncorporation": { "addr_line1": "", "addr_line2": "", "city": "", "state": "", "postal": "", "country": "" }, "q51_gi_TaxID": "96", "q58_gi_RegulatoryAuth": "", "q59_gi_LeiNumber": "", "q60_gi_LargeTraderID": "", "q62_gi_ComplianceContact": { "first": "", "last": "" }, "q64_gi_ComplianceEmail": "", "q63_gi_CompliancePhoneNumber": { "full": "" }, "q67_gi_IsSubsidiaryName": "", "q68_gi_IsSubsidiaryAddress": "", "q69_gi_IsSubsidiaryJurisdiction": "", "q70_gi_IsSubsidiaryRegulator": "", "q75_sc_OpsContact": { "first": "", "last": "" }, "q77_sc_OpsEmail": "", "q76_sc_OpsPhone": { "full": "" }, "q80_sc_OmgeoAcronym": "", "q81_sc_OmgeoAccessCode": "", "q82_sc_DTCNumber": "", "q83_sc_MPID": "", "q84_sc_AgentBankNumber": "", "q85_sc_InternalAccountNumber": "", "q86_sc_InstDelivery": "", "q87_sc_InterestedPartyID": "", "q88_sc_Custodian": "", "q89_sc_Euroclear": "", "q90_sc_Cedel": "", "q92_sc_ConfirmsEmail": "", "q101_ct_InstitutionalDVP": { "other": "" }, "q102_ct_InstitutionalDVPTypePublicDescription": "", "q108_ct_SectionA": ["Trust Co."], "q114_ct_SectionC": { "other": "" }, "q116_id_SectionA": { "0": "For a corporation, a Corporate Resolution and, if available, incorporation documents such as Articles of Incorporation and By-Laws", "other": "" }, "q121_ac_ControllingCustomerRelationship": "", "q123_ac_RegulatorBeneficialOwner": "No", "q125_ac_AccountBase": "", "q130_ac_CommercialEntity": "", "q132_ac_CommercialEntityOutsideUSFundsCountry": { "addr_line1": "", "addr_line2": "", "city": "", "state": "", "postal": "", "country": "" }, "q152_ac_ConfirmNeitherPrivBank": { "other": "" }, "q138_ac_CustomerRelationship": "Hi", "q161_signature": "Signed by David Test (dd@brownstone.com)", "q56_approvalStatus": "", "q159_ip": "", "q57_typeA": "https://form.jotform.com/82276720931155", "event_id": "1537887682362_82276720931155_ZPG71XZ", "q66_gi_IsSubsidiary": "", "q78_sc_Omgeo": "", "q91_sc_Confirms": "", "q97_sc_StructuredSecurities": "", "q98_sc_StructuredSecuritiesUnderstand": "", "q105_ct_MunicipalEntity": "", "q109_ct_SectionA2": "", "q111_ct_SectionB": "", "q112_ct_SectionBRelyingAdviser": "", "q120_ac_ControllingCustomer": "", "q126_ac_AMLProgram": "", "q128_ac_AMLRepresentationType": "", "q131_ac_CommercialEntityOutsideUSFunds": "", "q133_ac_CommercialEntityOutsideUSPresence": "", "q134_ac_CommercialEntityOutsideUSServiceShellBanks": "", "q157_id_SectionANA": "", "input95": ["https://www.jotform.com/uploads/ddinner/82276720931155/4136970043522095790/iShares-Fund-Changes-June-2018-vF.PDF"] } '; 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