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

Substitution

Processing...

Code Generator

Generated Code

re = /(?:http(s)?:\/\/(*SKIP))?(?(?<=(?::\/\/))(?:www\.)?|(?:www\.))((?:[\w-]+(?:\.[a-zA-Z0-9]{2,4}[\/?]?)))([\w\d-=+&\/]*)/ str = 'www.regex101.com/ https://regex101.com/a https://www.amazon.com/gp/yourstore/home/ref=topnav_ys_gw/002-2063622-5895250 <a href="http://www.regex101.com/">regex101.com/</a> Larry is survived by his wife, Sue of Waterloo, IA; two sons, Thomas (Peggy) Weber of Oak Park, IL, Ryan (Jaylene) Weber of Waterloo, IA; one daughter, Lori (Chris) Schutte of Jesup, IA; eight grandchildren, Scarlette and Jasper; Frank, Greta, and one on the way; Kalista, William, Ruby and Phoenix; three sisters, Sharon (Dan) Hambrock, Egan, MN, Judy (Jim) Meier, Tipton, IA, Marilyn (Victor) Kies, Cedar Rapids, IA; two brothers, Donald N. (Rose) Weber of Waterloo, Gerald W. “Gerry” (Shelly) Weber, Jesup; and two sisters-in-law, Brenda Weber of Jesup and Laura Weber of Raymond. He is preceded in death by one son, Matthew (May 18, 1983), his parents, Clarence (2002) and Darlys (2008); two sisters, Janice (1958) and LuAnn (1965); two brothers, Ronald H. Weber (2014) and Dale C. Weber (2015) and his mother-in-law, Beverly Swyers (2013). Funeral services were 10:30 a.m., Thursday, September 21, 2017, at Immaculate Conception Catholic Church, Gilbertville, IA with Rev. Henry Huber as celebrant with Deacon Al Weber assisting. Concelebrants also included Msgr. Ralph Simington, Fr. Lloyd Reuter and Fr. Jeffrey Dole. Music was by Bobbie Schares, organist, Todd Rohlfsen, soloist and the Resurrection Choir. Burial was at St. Joseph Catholic Cemetery, Raymond, IA. Casket Bearers were, Gerry Staebell, Steve Vogel, William Youngblut, Mike Reuter, Jim Breuer, Ted Monat, Adam Delagardelle, Jeremy Schmitz and Terry Hermeier. Visitation was at Immaculate Conception Catholic Church in Gilbertville on Wednesday from 3-7 p.m.; where there was a Knights of Columbus Rosary at 4 p.m. and Vigil service at 7p.m. Visitation continued for an hour before services Thursday also at the church. Memorials may be directed to the family for charitable donations or a charity of the donor’s choice. Online condolences may be posted at www.White-MtHope.com Larry is survived by his wife, Sue of Waterloo, IA; two sons, Thomas (Peggy) Weber of Oak Park, IL, Ryan (Jaylene) Weber of Waterloo, IA; one daughter, Lori (Chris) Schutte of Jesup, IA; eight grandchildren, Scarlette and Jasper; Frank, Greta, and one on the way; Kalista, William, Ruby and Phoenix; three sisters, Sharon (Dan) Hambrock, Egan, MN, Judy (Jim) Meier, Tipton, IA, Marilyn (Victor) Kies, Cedar Rapids, IA; two brothers, Donald N. (Rose) Weber of Waterloo, Gerald W. “Gerry” (Shelly) Weber, Jesup; and two sisters-in-law, Brenda Weber of Jesup and Laura Weber of Raymond. He is preceded in death by one son, Matthew (May 18, 1983), his parents, Clarence (2002) and Darlys (2008); two sisters, Janice (1958) and LuAnn (1965); two brothers, Ronald H. Weber (2014) and Dale C. Weber (2015) and his mother-in-law, Beverly Swyers (2013). Funeral services were 10:30 a.m., Thursday, September 21, 2017, at Immaculate Conception Catholic Church, Gilbertville, IA with Rev. Henry Huber as celebrant with Deacon Al Weber assisting. Concelebrants also included Msgr. Ralph Simington, Fr. Lloyd Reuter and Fr. Jeffrey Dole. Music was by Bobbie Schares, organist, Todd Rohlfsen, soloist and the Resurrection Choir. Burial was at St. Joseph Catholic Cemetery, Raymond, IA. Casket Bearers were, Gerry Staebell, Steve Vogel, William Youngblut, Mike Reuter, Jim Breuer, Ted Monat, Adam Delagardelle, Jeremy Schmitz and Terry Hermeier. Visitation was at Immaculate Conception Catholic Church in Gilbertville on Wednesday from 3-7 p.m.; where there was a Knights of Columbus Rosary at 4 p.m. and Vigil service at 7p.m. Visitation continued for an hour before services Thursday also at the church. Memorials may be directed to the family for charitable donations or a charity of the donor’s choice. Online condolences may be posted at www.White-MtHope.com Larry is survived by his wife, Sue of Waterloo, IA; two sons, Thomas (Peggy) Weber of Oak Park, IL, Ryan (Jaylene) Weber of Waterloo, IA; one daughter, Lori (Chris) Schutte of Jesup, IA; eight grandchildren, Scarlette and Jasper; Frank, Greta, and one on the way; Kalista, William, Ruby and Phoenix; three sisters, Sharon (Dan) Hambrock, Egan, MN, Judy (Jim) Meier, Tipton, IA, Marilyn (Victor) Kies, Cedar Rapids, IA; two brothers, Donald N. (Rose) Weber of Waterloo, Gerald W. “Gerry” (Shelly) Weber, Jesup; and two sisters-in-law, Brenda Weber of Jesup and Laura Weber of Raymond. He is preceded in death by one son, Matthew (May 18, 1983), his parents, Clarence (2002) and Darlys (2008); two sisters, Janice (1958) and LuAnn (1965); two brothers, Ronald H. Weber (2014) and Dale C. Weber (2015) and his mother-in-law, Beverly Swyers (2013). Funeral services were 10:30 a.m., Thursday, September 21, 2017, at Immaculate Conception Catholic Church, Gilbertville, IA with Rev. Henry Huber as celebrant with Deacon Al Weber assisting. Concelebrants also included Msgr. Ralph Simington, Fr. Lloyd Reuter and Fr. Jeffrey Dole. Music was by Bobbie Schares, organist, Todd Rohlfsen, soloist and the Resurrection Choir. Burial was at St. Joseph Catholic Cemetery, Raymond, IA. Casket Bearers were, Gerry Staebell, Steve Vogel, William Youngblut, Mike Reuter, Jim Breuer, Ted Monat, Adam Delagardelle, Jeremy Schmitz and Terry Hermeier. Visitation was at Immaculate Conception Catholic Church in Gilbertville on Wednesday from 3-7 p.m.; where there was a Knights of Columbus Rosary at 4 p.m. and Vigil service at 7p.m. Visitation continued for an hour before services Thursday also at the church. Memorials may be directed to the family for charitable donations or a charity of the donor’s choice. Online condolences may be posted at www.White-MtHope.com Larry is survived by his wife, Sue of Waterloo, IA; two sons, Thomas (Peggy) Weber of Oak Park, IL, Ryan (Jaylene) Weber of Waterloo, IA; one daughter, Lori (Chris) Schutte of Jesup, IA; eight grandchildren, Scarlette and Jasper; Frank, Greta, and one on the way; Kalista, William, Ruby and Phoenix; three sisters, Sharon (Dan) Hambrock, Egan, MN, Judy (Jim) Meier, Tipton, IA, Marilyn (Victor) Kies, Cedar Rapids, IA; two brothers, Donald N. (Rose) Weber of Waterloo, Gerald W. “Gerry” (Shelly) Weber, Jesup; and two sisters-in-law, Brenda Weber of Jesup and Laura Weber of Raymond. He is preceded in death by one son, Matthew (May 18, 1983), his parents, Clarence (2002) and Darlys (2008); two sisters, Janice (1958) and LuAnn (1965); two brothers, Ronald H. Weber (2014) and Dale C. Weber (2015) and his mother-in-law, Beverly Swyers (2013). Funeral services were 10:30 a.m., Thursday, September 21, 2017, at Immaculate Conception Catholic Church, Gilbertville, IA with Rev. Henry Huber as celebrant with Deacon Al Weber assisting. Concelebrants also included Msgr. Ralph Simington, Fr. Lloyd Reuter and Fr. Jeffrey Dole. Music was by Bobbie Schares, organist, Todd Rohlfsen, soloist and the Resurrection Choir. Burial was at St. Joseph Catholic Cemetery, Raymond, IA. Casket Bearers were, Gerry Staebell, Steve Vogel, William Youngblut, Mike Reuter, Jim Breuer, Ted Monat, Adam Delagardelle, Jeremy Schmitz and Terry Hermeier. Visitation was at Immaculate Conception Catholic Church in Gilbertville on Wednesday from 3-7 p.m.; where there was a Knights of Columbus Rosary at 4 p.m. and Vigil service at 7p.m. Visitation continued for an hour before services Thursday also at the church. Memorials may be directed to the family for charitable donations or a charity of the donor’s choice. Online condolences may be posted at www.White-MtHope.com Larry is survived by his wife, Sue of Waterloo, IA; two sons, Thomas (Peggy) Weber of Oak Park, IL, Ryan (Jaylene) Weber of Waterloo, IA; one daughter, Lori (Chris) Schutte of Jesup, IA; eight grandchildren, Scarlette and Jasper; Frank, Greta, and one on the way; Kalista, William, Ruby and Phoenix; three sisters, Sharon (Dan) Hambrock, Egan, MN, Judy (Jim) Meier, Tipton, IA, Marilyn (Victor) Kies, Cedar Rapids, IA; two brothers, Donald N. (Rose) Weber of Waterloo, Gerald W. “Gerry” (Shelly) Weber, Jesup; and two sisters-in-law, Brenda Weber of Jesup and Laura Weber of Raymond. He is preceded in death by one son, Matthew (May 18, 1983), his parents, Clarence (2002) and Darlys (2008); two sisters, Janice (1958) and LuAnn (1965); two brothers, Ronald H. Weber (2014) and Dale C. Weber (2015) and his mother-in-law, Beverly Swyers (2013). Funeral services were 10:30 a.m., Thursday, September 21, 2017, at Immaculate Conception Catholic Church, Gilbertville, IA with Rev. Henry Huber as celebrant with Deacon Al Weber assisting. Concelebrants also included Msgr. Ralph Simington, Fr. Lloyd Reuter and Fr. Jeffrey Dole. Music was by Bobbie Schares, organist, Todd Rohlfsen, soloist and the Resurrection Choir. Burial was at St. Joseph Catholic Cemetery, Raymond, IA. Casket Bearers were, Gerry Staebell, Steve Vogel, William Youngblut, Mike Reuter, Jim Breuer, Ted Monat, Adam Delagardelle, Jeremy Schmitz and Terry Hermeier. Visitation was at Immaculate Conception Catholic Church in Gilbertville on Wednesday from 3-7 p.m.; where there was a Knights of Columbus Rosary at 4 p.m. and Vigil service at 7p.m. Visitation continued for an hour before services Thursday also at the church. Memorials may be directed to the family for charitable donations or a charity of the donor’s choice. Online condolences may be posted at L ' subst = '<a href="http\\1://\\0">\\2</a>' result = str.gsub(re, subst) # Print the result of the substitution puts 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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html