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 = '/(.?(?:FROM)\ [a-zA-Z_]+(?:\.[a-zA-Z_]+)?)/'; $str = 'SELECT sl.subscription_link_id link_data_id , sl.subscription_id link_sub_id , a.adoption_id link_id , a.date_created link_start_date , dispatches.bill_charge_id link_charge_id , dispatches.total_amount link_amount , dispatches.status link_charge_status , dispatches.date_created link_charge_date_created , dispatches.date_modified link_charge_date_modified , dispatches.bill_fin_instrument_id charge_bill_fin_instrument_id , dispatches.date_resolved charge_resolved , dispatches.lp_exp_date charge_lp_exp_date , a.date_modified link_date_modified , a.date_created link_date_created , dispatches.base_price_type_id link_base_price_type_id , dispatches.status link_bill_charge_status , CASE WHEN ls.exp_date IS NOT NULL THEN ls.exp_date ELSE add_months(l.date_created, lp.num1 * DECODE(lp.num2,1,12,2,1) ) END link_end_date , CASE WHEN ls.exp_date IS NOT NULL THEN 1 ELSE (lp.num1 * DECODE(lp.num2,1,12,2,1,5,0,0)) END link_term FROM emetadata.ers_subscription_links sl , emetadata.ers_adoptions a , emetadata.ers_adopt_fulfillments af , emetadata.ers_licenses l , emetadata.ers_license_parameters lp , emetadata.ers_license_slots ls , (SELECT adopt_charge.bill_charge_id , adopt_charge.status ,adopt_charge.total_amount , partitions.date_resolved ,partitions.lp_exp_date , adopt_charge.adoption_id ,adopt_charge.date_created , adopt_charge.date_modified , adopt_charge.bill_fin_instrument_id , adopt_charge.base_price_type_id FROM (SELECT bc.bill_charge_id , bc.status , bc.date_created , bc.date_modified , bc.total_amount , bc.bill_fin_instrument_id , acl.adoption_id ,oicl.base_price_type_id FROM emetadata.ersmd_adoption_charge_link acl , emetadata.ers_bill_charge bc , emetadata.ers_order_charge_links oicl WHERE acl.charge_id = bc.bill_charge_id AND oicl.bill_charge_id = bc.bill_charge_id ) adopt_charge , (SELECT pcl.bill_charge_id , bd.date_resolved , cpi.lp_exp_date FROM emetadata.ers_bill_dispatches bd , emetadata.ers_charge_partitions cp , emetadata.ersmd_charge_partition_info cpi , emetadata.ers_part_charge_link pcl WHERE cp.charge_partition_id = bd.charge_partition_id (+) AND cp.charge_partition_id=cpi.charge_partition_id(+) AND cp.charge_partition_id = pcl.charge_partition_id AND cp.status = 3 ) partitions WHERE adopt_charge.bill_charge_id = partitions.bill_charge_id (+) ) dispatches WHERE a.subscription_link_id = sl.subscription_link_id AND af.adoption_id = a.adoption_id AND a.adoption_id = dispatches.adoption_id (+) AND af.fulfillment_target_id = l.license_id AND l.license_id = lp.license_id AND l.license_id = ls.license_id (+); '; 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