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

/
/
g

Test String

Code Generator

Generated Code

$re = '/Account: (\d+)/'; $str = 'John/Mary Tarro Family Trust 1 l\\/arlton Ct Sacramento, CA 95831 WATER CONSERVATION OFFICE 2260 GLEN ELLEN CIRCLE SACRAMENTO, CA 95822-3634 PH 916-808-5605 FAX 916-808-5655 Date: March 17,2015 Property Owner: John/Mary Tarro Family Trust Address: 1 lrarlton Ct Account: 8734444000 Parcel: 031 -0860-01 2-0000 Dear Customer: On, 12 Mar. 2015, al1 Marlton Ct, a City Water Conservation Representative observed the following violation(s) of the City\'s Water Conservation Ordinance: r Gutter or Pavement Flooding (SCCS13.04.860) n Flooding Neighbor (SCCS 13.04.860) . Watering Wrong Time (SCCS 13.04.870) X Watering Wrong Day (SCCS 13.04.870) r Leaking or Faulty Water Fixture(s) (SCCS 13.04.850) r Washing Vehicle on Wrong Day (SCCS 13.04.870) n Washing Vehicle Without Shut-Off Nozzle (SCCg 13.04.870) I Washing Down Paved Area (SCCS 13.04.870) sacramento city code section 13.04.890 imposes penalties for violations of the city\'s water Conservation Ordinance. Whether the violation is committed by the owner of the premises, or by the occupant (if different than the owner), the penalty amount is included on the owner\'s bill for water service provided to the premises where the violation occurred. Pagell of2 Notice of Violation Outdoor Water Conservation Requirements The penalty that applies to the violation(s) observed at the above address on 12 Mar. 2015 is checked below: X First violation during a twelve (12) month period: No penalty r Second violation during a twelve (12) month period: The penalty is flfty dollars ($50.00) However, this penalty will be waived if the owner, or the occupant (if different than the owner, and the occupant committed the violation) attends a Water Conservation Seminar offered by the City\'s Department of Utilities within sixty (60) days after the date of this penalty notice. - Third violation during a twelve (12) month period: The penalty is two hundred dollars (9200.00). r Fourth violation and any successive violations during a twelve (12) month period: The penalty is one thousand dollars ($1000.00). The owner or occupant of the premises where the violation(s) occurred may appeal this Notice of Violation by filing a written notice of appeal no later than 30 days from the date of this letter. Please send all appeals to the Water Conservation Office at 2260 Glen Ellen Cir., Sacramento, CA 95822, in accordance with the provisions of Sacramento City Code Section 13.04.900. The notice of appeal must specify the grounds for appeal and provide the address and telephone number of the person filing the appeal. Further information concerning the City\'s water conservation requirements and programs, including a link to the Sacramento City Code provisions cited in this Notice, may be viewed on the internet at www.sparesacwater.orq. Our website also contains information about free services available to help you manage your water use, such as a Free Water Wise House Call. With this free service, a trained Water Conservation Specialist will visit your home or business to identify potential water savings. We encourage you to take advantage of this service. lf you have any further questions, please call 31\'1 or (916) 264-5011. Durinq Dayliqht Savinqs TjnelMarch 8 - November 2) water TWO davs oer week, based on vour address number. Addresses endinq in odd numbers water Tues. and Sat.. addresses endin qr n even numbers water Weds. and City of Sacramento Department of Utilities, Water Conservation Office Page l2 of 2 Sun. - alwavs before 1Oam and after 7pm. Thank you, Page | 1 of 2 UPPENDAHL,JOEL R. 1 SAND PEBBLE CT SACRAMENTO, CA 95831 WATER CONSERVATION OFFICE 2260 GLEN ELLEN CIRCLE SACRAMENTO, CA 95822-3634 PH 916-808-5605 FAX 916-808-5655 Date: June 30, 2015 Notice of Violation Outdoor Water Conservation Requirements Property Owner: UPPENDAHL,JOEL R. Address: 1 SAND PEBBLE CT Account: 2919704886 Parcel: 031-1180-010-0000 Dear Customer: On, 6/26/2015, at 1 SAND PEBBLE CT, a City Water Conservation Representative observed the following violation(s) of the City’s Water Conservation Ordinance: X Gutter or Pavement Flooding (SCC§13.04.860) □ Flooding Neighbor (SCC§ 13.04.860) □ Watering Wrong Time (SCC§ 13.04.870) □ Watering Wrong Day (SCC§ 13.04.870) □ Leaking or Faulty Water Fixture(s) (SCC§ 13.04.850) □ Washing Vehicle on Wrong Day (SCC§ 13.04.870) □ Washing Vehicle Without Shut-Off Nozzle (SCC§ 13.04.870) □ Washing Down Paved Area (SCC§ 13.04.870) Sacramento City Code Section 13.04.890 imposes penalties for violations of the City’s Water Conservation Ordinance. Whether the violation is committed by the owner of the premises, or by the occupant (if different than the owner), the penalty amount is included on the owner’s bill for water service provided to the premises where the violation occurred. Page | 2 of 2 The penalty that applies to the violation(s) observed at the above address on 6/26/2015 is checked below: X First violation during a twelve (12) month period: No penalty. □ Second violation during a twelve (12) month period: The penalty is fifty dollars ($50.00). However, this penalty will be waived if the owner, or the occupant (if different than the owner, and the occupant committed the violation) attends a Water Conservation Seminar offered by the City’s Department of Utilities within sixty (60) days after the date of this penalty notice. □ Third violation during a twelve (12) month period: The penalty is two hundred dollars ($200.00). □ Fourth violation and any successive violations during a twelve (12) month period: The penalty is one thousand dollars ($1000.00). The owner or occupant of the premises where the violation(s) occurred may appeal this Notice of Violation by filing a written notice of appeal no later than 30 days from the date of this letter. Please send all appeals to the City’s Director of Utilities at 1395 35th Ave, Sacramento, CA 95822 in accordance with the provisions of Sacramento City Code Section 13.04.900. The notice of appeal must specify the grounds for appeal and provide the address and telephone number of the person filing the appeal. Further information concerning the City’s water conservation requirements and programs, including a link to the Sacramento City Code provisions cited in this Notice, may be viewed on the internet at www.sparesacwater.org. Our website also contains information about free services available to help you manage your water use, such as a Free Water Wise House Call. With this free service, a trained Water Conservation Specialist will visit your home or business to identify potential water savings. We encourage you to take advantage of this service. If you have any further questions, please call 311 or (916) 264-5011. During Daylight Saving Time (March 8 – November 2) water TWO days per week, based on your address number. Addresses ending in odd numbers water Tues. and Sat., addresses ending in even numbers water Weds. and Sun. – always before 10am and after 7pm. Thank you, City of Sacramento Department of Utilities, Water Conservation Office Page | 1 of 2 MARLIS WENDY JANG KOBASHI TRUST 2011 1 SIX RIVERS CR SACRAMENTO, CA 95831 WATER CONSERVATION OFFICE 2260 GLEN ELLEN CIRCLE SACRAMENTO, CA 95822-3634 PH 916-808-5605 FAX 916-808-5655 Date: March 31, 2015 Notice of Violation Outdoor Water Conservation Requirements Property Owner: MARLIS WENDY JANG KOBASHI TRUST 2011 Address: 1 SIX RIVERS CR Account: 364644000 Parcel: 031-0250-051-0000 Dear Customer: On, 3/26/2015, at 1 SIX RIVERS CR, a City Water Conservation Representative observed the following violation(s) of the City’s Water Conservation Ordinance: X Gutter or Pavement Flooding (SCC§13.04.860) □ Flooding Neighbor (SCC§ 13.04.860) □ Watering Wrong Time (SCC§ 13.04.870) X Watering Wrong Day (SCC§ 13.04.870) □ Leaking or Faulty Water Fixture(s) (SCC§ 13.04.850) □ Washing Vehicle on Wrong Day (SCC§ 13.04.870) □ Washing Vehicle Without Shut-Off Nozzle (SCC§ 13.04.870) □ Washing Down Paved Area (SCC§ 13.04.870) Sacramento City Code Section 13.04.890 imposes penalties for violations of the City’s Water Conservation Ordinance. Whether the violation is committed by the owner of the premises, or by the occupant (if different than the owner), the penalty amount is included on the owner’s bill for water service provided to the premises where the violation occurred. Page | 2 of 2 The penalty that applies to the violation(s) observed at the above address on 3/26/2015 is checked below: X First violation during a twelve (12) month period: No penalty. □ Second violation during a twelve (12) month period: The penalty is fifty dollars ($50.00). However, this penalty will be waived if the owner, or the occupant (if different than the owner, and the occupant committed the violation) attends a Water Conservation Seminar offered by the City’s Department of Utilities within sixty (60) days after the date of this penalty notice. □ Third violation during a twelve (12) month period: The penalty is two hundred dollars ($200.00). □ Fourth violation and any successive violations during a twelve (12) month period: The penalty is one thousand dollars ($1000.00). The owner or occupant of the premises where the violation(s) occurred may appeal this Notice of Violation by filing a written notice of appeal no later than 30 days from the date of this letter. Please send all appeals to the Water Conservation Office at 2260 Glen Ellen Cir., Sacramento, CA 95822, in accordance with the provisions of Sacramento City Code Section 13.04.900. The notice of appeal must specify the grounds for appeal and provide the address and telephone number of the person filing the appeal. Further information concerning the City’s water conservation requirements and programs, including a link to the Sacramento City Code provisions cited in this Notice, may be viewed on the internet at www.sparesacwater.org. Our website also contains information about free services available to help you manage your water use, such as a Free Water Wise House Call. With this free service, a trained Water Conservation Specialist will visit your home or business to identify potential water savings. We encourage you to take advantage of this service. If you have any further questions, please call 311 or (916) 264-5011. During Daylight Saving Time (March 8 – November 2) water TWO days per week, based on your address number. Addresses ending in odd numbers water Tues. and Sat., addresses ending in even numbers water Weds. and Sun. – always before 10am and after 7pm. Thank you, City of Sacramento Department of Utilities, Water Conservation Office Page | 1 of 2 MCKINNEY,ELIZABETH ANNE 2 KINGBIRD CT SACRAMENTO, CA 95831 WATER CONSERVATION OFFICE 2260 GLEN ELLEN CIRCLE SACRAMENTO, CA 95822-3634 PH 916-808-5605 FAX 916-808-5655 Date: April 29, 2015 Notice of Violation Outdoor Water Conservation Requirements Property Owner: MCKINNEY,ELIZABETH ANNE Address: 2 KINGBIRD CT Account: 7728344000 Parcel: 031-0370-054-0000 Dear Customer: On, 4/20/2015, at 2 KINGBIRD CT, a City Water Conservation Representative observed the following violation(s) of the City’s Water Conservation Ordinance: X Gutter or Pavement Flooding (SCC§13.04.860) □ Flooding Neighbor (SCC§ 13.04.860) □ Watering Wrong Time (SCC§ 13.04.870) X Watering Wrong Day (SCC§ 13.04.870) □ Leaking or Faulty Water Fixture(s) (SCC§ 13.04.850) □ Washing Vehicle on Wrong Day (SCC§ 13.04.870) □ Washing Vehicle Without Shut-Off Nozzle (SCC§ 13.04.870) □ Washing Down Paved Area (SCC§ 13.04.870) Sacramento City Code Section 13.04.890 imposes penalties for violations of the City’s Water Conservation Ordinance. Whether the violation is committed by the owner of the premises, or by the occupant (if different than the owner), the penalty amount is included on the owner’s bill for water service provided to the premises where the violation occurred. Page | 2 of 2 The penalty that applies to the violation(s) observed at the above address on 4/20/2015 is checked below: X First violation during a twelve (12) month period: No penalty. □ Second violation during a twelve (12) month period: The penalty is fifty dollars ($50.00). However, this penalty will be waived if the owner, or the occupant (if different than the owner, and the occupant committed the violation) attends a Water Conservation Seminar offered by the City’s Department of Utilities within sixty (60) days after the date of this penalty notice. □ Third violation during a twelve (12) month period: The penalty is two hundred dollars ($200.00). □ Fourth violation and any successive violations during a twelve (12) month period: The penalty is one thousand dollars ($1000.00). The owner or occupant of the premises where the violation(s) occurred may appeal this Notice of Violation by filing a written notice of appeal no later than 30 days from the date of this letter. Please send all appeals to the Water Conservation Office at 2260 Glen Ellen Cir., Sacramento, CA 95822, in accordance with the provisions of Sacramento City Code Section 13.04.900. The notice of appeal must specify the grounds for appeal and provide the address and telephone number of the person filing the appeal. Further information concerning the City’s water conservation requirements and programs, including a link to the Sacramento City Code provisions cited in this Notice, may be viewed on the internet at www.sparesacwater.org. Our website also contains information about free services available to help you manage your water use, such as a Free Water Wise House Call. With this free service, a trained Water Conservation Specialist will visit your home or business to identify potential water savings. We encourage you to take advantage of this service. If you have any further questions, please call 311 or (916) 264-5011. During Daylight Saving Time (March 8 – November 2) water TWO days per week, based on your address number. Addresses ending in odd numbers water Tues. and Sat., addresses ending in even numbers water Weds. and Sun. – always before 10am and after 7pm. Thank you, City of Sacramento Department of Utilities, Water Conservation Office Page | 1 of 2 GRIFFIN,ROBERT E 4 KEELING CT SACRAMENTO, CA 95823 WATER CONSERVATION OFFICE 2260 GLEN ELLEN CIRCLE SACRAMENTO, CA 95822-3634 PH 916-808-5605 FAX 916-808-5655 Date: June 1, 2015 Notice of Violation Outdoor Water Conservation Requirements Property Owner: GRIFFIN,ROBERT E Address: 4 KEELING CT Account: 5514844000 Parcel: 117-0970-103-0000 Dear Customer: On, 5/28/2015, at 4 KEELING CT, a City Water Conservation Representative observed the following violation(s) of the City’s Water Conservation Ordinance: X Gutter or Pavement Flooding (SCC§13.04.860) □ Flooding Neighbor (SCC§ 13.04.860) □ Watering Wrong Time (SCC§ 13.04.870) X Watering Wrong Day (SCC§ 13.04.870) □ Leaking or Faulty Water Fixture(s) (SCC§ 13.04.850) □ Washing Vehicle on Wrong Day (SCC§ 13.04.870) □ Washing Vehicle Without Shut-Off Nozzle (SCC§ 13.04.870) □ Washing Down Paved Area (SCC§ 13.04.870) Sacramento City Code Section 13.04.890 imposes penalties for violations of the City’s Water Conservation Ordinance. Whether the violation is committed by the owner of the premises, or by the occupant (if different than the owner), the penalty amount is included on the owner’s bill for water service provided to the premises where the violation occurred. Page | 2 of 2 The penalty that applies to the violation(s) observed at the above address on 5/28/2015 is checked below: □ First violation during a twelve (12) month period: No penalty. X Second violation during a twelve (12) month period: The penalty is fifty dollars ($50.00). However, this penalty will be waived if the owner, or the occupant (if different than the owner, and the occupant committed the violation) attends a Water Conservation Seminar offered by the City’s Department of Utilities within sixty (60) days after the date of this penalty notice. □ Third violation during a twelve (12) month period: The penalty is two hundred dollars ($200.00). □ Fourth violation and any successive violations during a twelve (12) month period: The penalty is one thousand dollars ($1000.00). The owner or occupant of the premises where the violation(s) occurred may appeal this Notice of Violation by filing a written notice of appeal no later than 30 days from the date of this letter. Please send all appeals to the City’s Director of Utilities at 1395 35th Ave, Sacramento, CA 95822 in accordance with the provisions of Sacramento City Code Section 13.04.900. The notice of appeal must specify the grounds for appeal and provide the address and telephone number of the person filing the appeal. Further information concerning the City’s water conservation requirements and programs, including a link to the Sacramento City Code provisions cited in this Notice, may be viewed on the internet at www.sparesacwater.org. Our website also contains information about free services available to help you manage your water use, such as a Free Water Wise House Call. With this free service, a trained Water Conservation Specialist will visit your home or business to identify potential water savings. We encourage you to take advantage of this service. If you have any further questions, please call 311 or (916) 264-5011. During Daylight Saving Time (March 8 – November 2) water TWO days per week, based on your address number. Addresses ending in odd numbers water Tues. and Sat., addresses ending in even numbers water Weds. and Sun. – always before 10am and after 7pm. Thank you, City of Sacramento Department of Utilities, Water Conservation Office Page | 1 of 2 SPENCER,ZACHARY B 4 VESTRY CT SACRAMENTO, CA 95835 WATER CONSERVATION OFFICE 2260 GLEN ELLEN CIRCLE SACRAMENTO, CA 95822-3634 PH 916-808-5605 FAX 916-808-5655 Date: March 2, 2015 Notice of Violation Outdoor Water Conservation Requirements Property Owner: SPENCER,ZACHARY B Address: 4 VESTRY CT Account: 6205648708 Parcel: 225-1140-050-0000 Dear Customer: On, 3/2/2015, at 4 VESTRY CT, a City Water Conservation Representative observed the following violation(s) of the City’s Water Conservation Ordinance: X Gutter or Pavement Flooding (SCC§13.04.860) □ Flooding Neighbor (SCC§ 13.04.860) □ Watering Wrong Time (SCC§ 13.04.870) □ Watering Wrong Day (SCC§ 13.04.870) □ Leaking or Faulty Water Fixture(s) (SCC§ 13.04.850) □ Washing Vehicle on Wrong Day (SCC§ 13.04.870) □ Washing Vehicle Without Shut-Off Nozzle (SCC§ 13.04.870) □ Washing Down Paved Area (SCC§ 13.04.870) Sacramento City Code Section 13.04.890 imposes penalties for violations of the City’s Water Conservation Ordinance. Whether the violation is committed by the owner of the premises, or by the occupant (if different than the owner), the penalty amount is included on the owner’s bill for water service provided to the premises where the violation occurred. Page | 2 of 2 The penalty that applies to the violation(s) observed at the above address on 3/2/2015 is checked below: X First violation during a twelve (12) month period: No penalty. □ Second violation during a twelve (12) month period: The penalty is fifty dollars ($50.00). However, this penalty will be waived if the owner, or the occupant (if different than the owner, and the occupant committed the violation) attends a Water Conservation Seminar offered by the City’s Department of Utilities within sixty (60) days after the date of this penalty notice. □ Third violation during a twelve (12) month period: The penalty is two hundred dollars ($200.00). □ Fourth violation and any successive violations during a twelve (12) month period: The penalty is one thousand dollars ($1000.00). The owner or occupant of the premises where the violation(s) occurred may appeal this Notice of Violation by filing a written notice of appeal'; 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