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
No Match

r"
"
gmsu

Test String

Code Generator

Generated Code

import java.util.regex.Matcher; import java.util.regex.Pattern; public class Example { public static void main(String[] args) { final String regex = "^\\s?[\\u1040-\\u1049]{1,2}။\\s?(?:[\\u1000-\\u104F\\s\\-\\(\\)]+)(?:[\\w\\s\\(\\)&\\.]+)-(.*?)\\n"; final String string = "ကိုယ်တိုင်ရေးပုံတူ\n" + "၁။ ကိုယ်တိုင်ရေးပုံတူ Art Company - Suzanna\n" + "၂။ ဘာအကောင်းဆုံးလည်း Australian Crawl - The Boys Light Up\n" + "၃။ အချစ်ကြေညာစာတမ်း The Art Company - Maybe Tomorrow\n" + "၄။ ကော်ဖီခါးခါး John Cougar - Authority Song\n" + "၅။ တချို့ကကံကောင်းတယ် The Persuaders - Some Guys Have All the Luck\n" + "၆။ မမရောဂါ The Art Company - Eileen\n" + "၇။ ကြေးစား The Hooters- All You Zombies (credit to @Tun Tun songbook)\n" + "၈။ အပြင်လူ-Danger List - John.C.Mellencamp\n" + "၉။ မာယာ Saphir - I Feel Good\n" + "၁၀။ အက်ဆစ်ဝိုင်ချို John.C Mellencamp - Rain on the Scarecrow\n" + "၁၁။ စက်ရုပ်မဟုတ်ဘူး Greg Kihn Band - The Break Up Song\n" + "၁၂။ အချစ်ဒိဋ္ဌိ Smokie - Stranger\n" + "၁၃။ စိန်ခေါ်ပွဲ Geff Harrison - Bad New York City\n" + "၁၄။ သင်္ဘောမှောက်ခြင်း Joe Cocker - Don't You Love Me Anymore\n\n" + "“ ကော်ဖီခါးခါး “\n" + "၁။ ကော်ဖီခါးခါး John Cougar - Authority song\n" + "၂။ တချို့ကကံကောင်းတယ် The Shaker - Some guys have all the luck (The Persuaders)\n" + "၃။ ထမိန်တိုတို ရှန်ပိန် Julian Lennon - Too late for goodbyes\n" + "၄။ ကိုယ်တိုင်ရေးပုံတူ The Art Company - Susanna\n" + "၅။ လေဟာနယ်ထဲမှာ Sutherland Brothers and Quiver - Dr Dancer\n" + "၆။ အိမ်မက်ဝိုင် Sutherland Brothers and Quiver - Arms of Mary\n" + "၇။ မင်းသဘော Bread - Let your love go\n" + "၈။ အချစ်ဝိုင် Bonnie Tyler - Here she comes\n" + "၉။ စက်ရုပ်မဟုတ်ဘူး Greg Khin Band - The break up song\n" + "၁၀။ တင်းနစ်သမား Chris Rea - Tennis\n" + "၁၁။ အပြင်လူ John Cougar - Danger list\n" + "၁၂။ မာရ်နတ်ရဲ့ သမီး Albert Hammond - Peacemaker\n" + "၁၃။ သစ္စာ (အကျိုးပြု) Billy Joel - Honesty\n" + "၁၄။ မျက်ရည်ကျရင် အရှုံး America - And forever\n" + "၁၅။ ရွှေရောင်အာရုဏ် Steve Miller Band - Swing town\n\n" + "“မျှော်လင့်ချက်”\n" + "၁။ ချိုသဲ Craig Mclachaln & Check - Mona\n" + "၂။ အမောပြေ လရောင် ??????\n" + "၃။ လှသောပြသနာ ??????\n" + "၄။ လွဲချော်ခြင်း The Beatles - Don't let me down\n" + "၅။ မျှော်လင့်ချက် ??????\n" + "၆။ ရက်ရက်စက်စက် Bonnie Tyler - Take me back\n" + "၇။ ကလေးတစ်ယောက်အိမ်မက် Freddie Augllia - Anak\n" + "၈။ သာရွေ့ဝေးသော Bon Jovi - Runaway\n" + "၉။ အသည်းအသန်ည Bonnie Tyler - My guns are loaded\n" + "၁၀။ မျက်နှာဖုံး Men at Work - Down under\n" + "၁၁။ တစ်ဖက်သတ်အချစ် ???????\n" + "၁၂။ ပထမ အသည်းကွဲဇာတ်လမ်း Smokie - Living next door to alice\n" + "၁၃။ ရင်အခုန်အခ ျစ် Tanya Tucker - A thing called love\n" + "၁၄။ သံသရာ Scorpions - Is there anybody there\n" + "၁၅။ အားလုံး Culture Club - Everything I own (original Bread)\n\n" + "“ယန္တာရား”\n" + "၁။ ယန္တရား John Cougar - Human wheel\n" + "၂။ တခါတရံ အချစ်ဆိုသည်မှာ ခံစားမှုသက်သက်မျှသာ Notting Hillbillies - Will you miss me\n" + "၃။ မရှောင်နိုင်ဘူး ချစ်မိတယ် UB 40 - Can't help falling in love (original Elvis Presley )\n" + "၄။ ၀ိုင်ခွက် ပါးပါး အရက်ပြင်းပြင်း Billy Ray Cyrus - Achy break heart (The Marcy Brothers)\n" + "၅။ လှပသော အမှန်တရား John Cougar - Pretty Woman (Roy Orbison )\n" + "၆။ အနီးအဝေး ပြသနာ The Hooters - 500 miles (The Journey Men )\n" + "၇။ ကံကြမ္မာဇာတ်လမ်း Smokie - Don't play your Rock N Roll to me\n" + "၈။ သံသယ John Lennon - Jealous Guy\n" + "၉။ ဘယ်သူမှ အပြစ်မရှိ ?????\n" + "၁၀။ ခိုလှုံရာ Tom Petty - Spikes\n" + "၁၁။ ယုံကြည်ခြင်း George Michael - Faith\n" + "၁၂။ သံသရာအပြေးသမား ?????\n" + "၁၃။ စွှန့်စားခန်း Steve Earl - Copper road\n" + "၁၄။ အချစ်ရဲ့ ရွှေ Billy Idol - Mony Mony (Tommy James)\n\n" + "ရောခ့်သူရဲကောင်းများ ချစ်ကောင်း + ဇော်ဝင်းထွဋ် -\n" + "၂။ ကျားတွေက မငိုဘူး ( Tokyo Square - Say you will)\n" + "၄။ အိမ်အပြန် ( Bryan Adams - Summer of 69)\n" + "၆။ ကိုယ်လိုလူတွေအများကြီး ( <song-Ao Bpai Loey เอาไปเลย/Take It> <artist - Micro/ไมโคร )\n" + "၈။ မင်းမဟုတ်သလိုပဲ ( Eddie Money - Shakin )\n" + "၁၀။ ပြေးလို့လွတ်မှာလား (Stray Cats - Bring it back again)\n" + "၁၂။ အချစ်မှ ဟုတ်ရဲ့လား Greg Khin Band - With The Naked Eye\n" + "၁၄။ မိုးအောက်မြေပြင် (The Hooters - Johnny B)\n\n" + "မင်္ဂလာပါလောက (ချစ်ကောင်း + ဟေမာနေဝင်း)\n" + "၁။ ချစ်ကောင်း - မင်္ဂလာပါလောက Thai Song\n" + "၃။ ချစ်ကောင်း - အစ်ကိုရေဘာလိုသေးလဲ (The Hooters - Brother don't you walk away)\n" + "၅။ ချစ်ကောင်း - လွမ်းသူ (George Harrison - Gone Troppo)\n" + "၆။ ချစ်ကောင်း - စတော်ဘယ်ရီအိပ်မက် (Smokie - Yesterday dream)\n" + "၁၀။ ချစ်ကောင်း - သံယောဇဉ် (Nick Kamen - Don't hold out)\n" + "၁၂။ ချစ်ကောင်း - ငါ့အချစ်တွေ လျော့ (Marty Straut - Hill Billy rock)\n" + "၁၄။ ချစ်ကောင်း - သေသေချာချာလုပ် (Bonnie Tyler - Hide your heart) original-Ace Frehley\n\n" + "သင်္ကေတ (ချစ်ကောင်း + လေးလေးဝါး)\n" + "၁။ လေးလေးဝါး - ရင်ထဲက ပုဏ္ဍား (Funky Diamonds - I Know That You Want Me)\n" + "၂။ ချစ်ကောင်း + လေးလေးဝါး - ဖြေတော့ (UB 40 + Chrissie Hynde - I Got You Babe) Original - Sony + Cher\n" + "၃။ ချစ်ကောင်း - သင်္ကေတ (Search - Fatansia Bulan Madu) Malasian Song\n" + "၄။ လေးလေးဝါး - အရူးအမူးချစ်မိခြင်း(Celion Dion - Treat Her Like A Lady)\n" + "၅။ ချစ်ကောင်း - မျှော်နေသူအတွက်နောက်ဆုံးည (Eric Camen - Hold Me Now)\n" + "၆။ လေးလေးဝါး - အရိုင်းလေး (Toni Braxton - Un - Breaken My Heart)\n" + "၇။ ချစ်ကောင်း - အလွမ်းဆုံးနေ့ (UB 40 - Here I Am)\n" + "၈။ လေးလေးဝါး - အချစ်ရဲ့ကျေးကျွန်(Malaysian Song)\n" + "၉။ ချစ်ကောင်း - မရှိမဖြစ်.....မရှိ (Damn Yankees - Silence Is Broken)\n" + "၁၀။ လေးလေးဝါး - မရှိတော့မှ (Le Ann Rimes - How Do I live )\n" + "၁၁။ ချစ်ကောင်း - အစွန်းတစ်ဖက် (Wings - Pernafas Oalam Lumpur) Malaysian Song"; final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE | Pattern.DOTALL | Pattern.UNICODE_CASE); final Matcher matcher = pattern.matcher(string); while (matcher.find()) { System.out.println("Full match: " + matcher.group(0)); for (int i = 1; i <= matcher.groupCount(); i++) { System.out.println("Group " + i + ": " + matcher.group(i)); } } } }

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 Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html