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

/
/
gmui

Test String

Code Generator

Generated Code

#include <StringConstants.au3> ; to declare the Constants of StringRegExp #include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate Local $sRegex = "(?mui)([ぁ-ゟ])" Local $sString = "Regex for matching ALL Japanese common & uncommon Kanji (4e00 – 9fcf) ~ The Big Kahuna!" & @CRLF & _ "([一-龯])" & @CRLF & _ "" & @CRLF & _ "Regex for matching Hirgana or Katakana" & @CRLF & _ "([ぁ-んァ-ン])" & @CRLF & _ "" & @CRLF & _ "Regex for matching Non-Hirgana or Non-Katakana" & @CRLF & _ "([^ぁ-んァ-ン])" & @CRLF & _ "" & @CRLF & _ "Regex for matching Hirgana or Katakana or basic punctuation (、。’)" & @CRLF & _ "([ぁ-んァ-ン\w])" & @CRLF & _ "" & @CRLF & _ "Regex for matching Hirgana or Katakana and random other characters" & @CRLF & _ "([ぁ-んァ-ン!:/])" & @CRLF & _ "" & @CRLF & _ "Regex for matching Hirgana" & @CRLF & _ "([ぁ-ん])" & @CRLF & _ "" & @CRLF & _ "Regex for matching full-width Katakana (zenkaku 全角)" & @CRLF & _ "([ァ-ン])" & @CRLF & _ "" & @CRLF & _ "Regex for matching half-width Katakana (hankaku 半角)" & @CRLF & _ "([ァ-ン゙゚])" & @CRLF & _ "" & @CRLF & _ "Regex for matching full-width Numbers (zenkaku 全角)" & @CRLF & _ "([0-9])" & @CRLF & _ "" & @CRLF & _ "Regex for matching full-width Letters (zenkaku 全角)" & @CRLF & _ "([A-z])" & @CRLF & _ "" & @CRLF & _ "Regex for matching Hiragana codespace characters (includes non phonetic characters)" & @CRLF & _ "([ぁ-ゞ])" & @CRLF & _ "" & @CRLF & _ "Regex for matching full-width (zenkaku) Katakana codespace characters (includes non phonetic characters)" & @CRLF & _ "([ァ-ヶ])" & @CRLF & _ "" & @CRLF & _ "Regex for matching half-width (hankaku)" & @CRLF & _ "Katakana codespace characters (this is an old character set so the order is inconsistent with the hiragana)" & @CRLF & _ "([ヲ-゚])" & @CRLF & _ "" & @CRLF & _ "Regex for matching Japanese Post Codes" & @CRLF & _ "/^¥d{3}¥-¥d{4}$/" & @CRLF & _ "/^¥d{3}-¥d{4}$|^¥d{3}-¥d{2}$|^¥d{3}$/" & @CRLF & _ "" & @CRLF & _ "Regex for matching Japanese mobile phone numbers (keitai bangou)" & @CRLF & _ "/^¥d{3}-¥d{4}-¥d{4}$|^¥d{11}$/" & @CRLF & _ "/^0¥d0-¥d{4}-¥d{4}$/" & @CRLF & _ "" & @CRLF & _ "Regex for matching Japanese fixed line phone numbers" & @CRLF & _ "/^[0-9-]{6,9}$|^[0-9-]{12}$/" & @CRLF & _ "/^¥d{1,4}-¥d{4}$|^¥d{2,5}-¥d{1,4}-¥d{4}$/" & @CRLF & _ "" & @CRLF & _ "Match all English alphanumerics, Japanese katakana,hiragana,multibytes of alphanumerics [hankaku and zenkaku],dashes" & @CRLF & _ "/[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー]+|[a-zA-Z0-9]+|[a-zA-Z0-9]+[々〆〤]+/u" & @CRLF & _ "========================================================" & @CRLF & _ "--------------------------------------------------------" & @CRLF & _ "Half-width alphanumeric characters" & @CRLF & _ "([!-~])" & @CRLF & _ "" & @CRLF & _ "!"#$%&'()*+,-./0123456789:;<=>?" & @CRLF & _ "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_" & @CRLF & _ "`abcdefghijklmnopqrstuvwxyz{|}~€" & @CRLF & _ "" & @CRLF & _ "--------------------------------------------------------" & @CRLF & _ "Half-width KANA (hard)" & @CRLF & _ "" & @CRLF & _ "。「」、・ヲァィゥェォャュョッーアイウエオカキクケコサシスセソ" & @CRLF & _ "タチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙゚" & @CRLF & _ "" & @CRLF & _ "--------------------------------------------------------" & @CRLF & _ "Full-width alphanumeric characters" & @CRLF & _ "" & @CRLF & _ "0123456789" & @CRLF & _ "ABCDEFGHIJKLMNOP" & @CRLF & _ "QRSTUVWXYZabcdef" & @CRLF & _ "ghijklmnopqrstuv" & @CRLF & _ "wxyz" & @CRLF & _ "" & @CRLF & _ "--------------------------------------------------------" & @CRLF & _ "full-width KANA (soft)" & @CRLF & _ "" & @CRLF & _ "ぁあぃいぅうぇえぉおかがきぎくぐ" & @CRLF & _ "けげこごさざしじすずせぜそぞただ" & @CRLF & _ "ちぢっつづてでとどなにぬねのはば" & @CRLF & _ "ぱひびぴふぶぷへべぺほぼぽまみむ" & @CRLF & _ "めもゃやゅゆょよらりるれろゎわゐ" & @CRLF & _ "ゑをん" & @CRLF & _ "" & @CRLF & _ "--------------------------------------------------------" & @CRLF & _ "full-width KANA (hard)" & @CRLF & _ "" & @CRLF & _ "ァアィイゥウェエォオカガキギクグ" & @CRLF & _ "ケゲコゴサザシジスズセゼソゾタダ" & @CRLF & _ "チヂッツヅテデトドナニヌネノハバ" & @CRLF & _ "パヒビピフブプヘベペホボポマミム" & @CRLF & _ "メモャヤュユョヨラリルレロヮワヰ" & @CRLF & _ "ヱヲンヴヵヶ" & @CRLF & _ "" & @CRLF & _ "--------------------------------------------------------" & @CRLF & _ "Symbol" & @CRLF & _ "" & @CRLF & _ "、。,.・:;?!゛゜´`¨^ ̄" & @CRLF & _ "_ヽヾゝゞ〃仝々〆〇ー―‐/\~" & @CRLF & _ "∥|…‥‘’“”()〔〕[]{}" & @CRLF & _ "〈〉《》「」『』【】+-±×÷=" & @CRLF & _ "≠<>≦≧∞∴♂♀°′″℃¥$¢" & @CRLF & _ "£%#&*@§☆★○●◎◇◆□■" & @CRLF & _ "△▲▽▼※〒→←↑↓〓∈∋⊆⊇⊂" & @CRLF & _ "⊃∪∩∧∨¬⇒⇔∀∃∠⊥⌒∂∇≡" & @CRLF & _ "≒≪≫√∽∝∵∫∬ʼn♯♭♪" & @CRLF & _ "---------------------------------------------------------" & @CRLF & _ "" & @CRLF & _ "Hiragana" & @CRLF & _ "Unicode code points regex: [\x3041-\x3096]" & @CRLF & _ "Unicode block property regex: \p{Hiragana}" & @CRLF & _ "Regex: ([ぁ-ゟ])" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "ぁ あ ぃ い ぅ う ぇ え ぉ お か が き ぎ く ぐ け げ こ ご さ ざ し じ す ず せ ぜ そ ぞ た だ ち ぢ っ つ づ て で と ど な に ぬ ね の は ば ぱ ひ び ぴ ふ ぶ ぷ へ べ ぺ ほ ぼ ぽ ま み む め も ゃ や ゅ ゆ ょ よ ら り る れ ろ ゎ わ ゐ ゑ を ん ゔ ゕ ゖ ゙ ゚ ゛ ゜ ゝ ゞ ゟ" & @CRLF & _ "---------------------------------------------------------" & @CRLF & _ "Katakana (Full Width)" & @CRLF & _ "Unicode code points regex: [\x30A0-\x30FF]" & @CRLF & _ "Unicode block property regex: \p{Katakana}" & @CRLF & _ "([ァ-ヿ])" & @CRLF & _ "" & @CRLF & _ "゠ ァ ア ィ イ ゥ ウ ェ エ ォ オ カ ガ キ ギ ク グ ケ ゲ コ ゴ サ ザ シ ジ ス ズ セ ゼ ソ ゾ タ ダ チ ヂ ッ ツ ヅ テ デ ト ド ナ ニ ヌ ネ ノ ハ バ パ ヒ ビ ピ フ ブ プ ヘ ベ ペ ホ ボ ポ マ ミ ム メ モ ャ ヤ ュ ユ ョ ヨ ラ リ ル レ ロ ヮ ワ ヰ ヱ ヲ ン ヴ ヵ ヶ ヷ ヸ ヹ ヺ ・ ー ヽ ヾ ヿ" & @CRLF & _ "---------------------------------------------------------" & @CRLF & _ "Kanji" & @CRLF & _ "Unicode code points regex: [\x3400-\x4DB5\x4E00-\x9FCB\xF900-\xFA6A]" & @CRLF & _ "Unicode block property regex: \p{Han}" & @CRLF & _ "Regex: ([㐀-䶵一-鿋豈-頻])" & @CRLF & _ "" & @CRLF & _ "漢字 日本語 文字 言語 言葉 etc. Too many characters to list." & @CRLF & _ "" & @CRLF & _ "This regular expression will match all the kanji, including those used in Chinese." & @CRLF & _ "---------------------------------------------------------" & @CRLF & _ "Kanji Radicals" & @CRLF & _ "Unicode code points regex: [\x2E80-\x2FD5]" & @CRLF & _ "Regex: ([⺀-⿕])" & @CRLF & _ "" & @CRLF & _ "⺀ ⺁ ⺂ ⺃ ⺄ ⺅ ⺆ ⺇ ⺈ ⺉ ⺊ ⺋ ⺌ ⺍ ⺎ ⺏ ⺐ ⺑ ⺒ ⺓ ⺔ ⺕ ⺖ ⺗ ⺘ ⺙ ⺚ ⺛ ⺜ ⺝ ⺞ ⺟ ⺠ ⺡ ⺢ ⺣ ⺤ ⺥ ⺦ ⺧ ⺨ ⺩ ⺪ ⺫ ⺬ ⺭ ⺮ ⺯ ⺰ ⺱ ⺲ ⺳ ⺴ ⺵ ⺶ ⺷ ⺸ ⺹ ⺺ ⺻ ⺼ ⺽ ⺾ ⺿ ⻀ ⻁ ⻂ ⻃ ⻄ ⻅ ⻆ ⻇ ⻈ ⻉ ⻊ ⻋ ⻌ ⻍ ⻎ ⻏ ⻐ ⻑ ⻒ ⻓ ⻔ ⻕ ⻖ ⻗ ⻘ ⻙ ⻚ ⻛ ⻜ ⻝ ⻞ ⻟ ⻠ ⻡ ⻢ ⻣ ⻤ ⻥ ⻦ ⻧ ⻨ ⻩ ⻪ ⻫ ⻬ ⻭ ⻮ ⻯ ⻰ ⻱ ⻲ ⻳" & @CRLF & _ "⼀ ⼁ ⼂ ⼃ ⼄ ⼅ ⼆ ⼇ ⼈ ⼉ ⼊ ⼋ ⼌ ⼍ ⼎ ⼏ ⼐ ⼑ ⼒ ⼓ ⼔ ⼕ ⼖ ⼗ ⼘ ⼙ ⼚ ⼛ ⼜ ⼝ ⼞ ⼟ ⼠ ⼡ ⼢ ⼣ ⼤ ⼥ ⼦ ⼧ ⼨ ⼩ ⼪ ⼫ ⼬ ⼭ ⼮ ⼯ ⼰ ⼱ ⼲ ⼳ ⼴ ⼵ ⼶ ⼷ ⼸ ⼹ ⼺ ⼻ ⼼ ⼽ ⼾ ⼿ ⽀ ⽁ ⽂ ⽃ ⽄ ⽅ ⽆ ⽇ ⽈ ⽉ ⽊ ⽋ ⽌ ⽍ ⽎ ⽏ ⽐ ⽑ ⽒ ⽓ ⽔ ⽕ ⽖ ⽗ ⽘ ⽙ ⽚ ⽛ ⽜ ⽝ ⽞ ⽟ ⽠ ⽡ ⽢ ⽣ ⽤ ⽥ ⽦ ⽧ ⽨ ⽩ ⽪ ⽫ ⽬ ⽭ ⽮ ⽯ ⽰ ⽱ ⽲ ⽳ ⽴ ⽵ ⽶ ⽷ ⽸ ⽹ ⽺ ⽻ ⽼ ⽽ ⽾ ⽿ ⾀ ⾁ ⾂ ⾃ ⾄ ⾅ ⾆ ⾇ ⾈ ⾉ ⾊ ⾋ ⾌ ⾍ ⾎ ⾏ ⾐ ⾑ ⾒ ⾓ ⾔ ⾕ ⾖ ⾗ ⾘ ⾙ ⾚ ⾛ ⾜ ⾝ ⾞ ⾟ ⾠ ⾡ ⾢ ⾣ ⾤ ⾥ ⾦ ⾧ ⾨ ⾩ ⾪ ⾫ ⾬ ⾭ ⾮ ⾯ ⾰ ⾱ ⾲ ⾳ ⾴ ⾵ ⾶ ⾷ ⾸ ⾹ ⾺ ⾻ ⾼ ⾽ ⾾ ⾿ ⿀ ⿁ ⿂ ⿃ ⿄ ⿅ ⿆ ⿇ ⿈ ⿉ ⿊ ⿋ ⿌ ⿍ ⿎ ⿏ ⿐ ⿑ ⿒ ⿓ ⿔ ⿕" & @CRLF & _ "---------------------------------------------------------" & @CRLF & _ "Katakana and Punctuation (Half Width)" & @CRLF & _ "Unicode code points regex: [\xFF5F-\xFF9F]" & @CRLF & _ "Regex: ([⦅-ン])" & @CRLF & _ "" & @CRLF & _ "⦅ ⦆ 。 「 」 、 ・ ヲ ァ ィ ゥ ェ ォ ャ ュ ョ ッ ー ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ン ゙" & @CRLF & _ "---------------------------------------------------------" & @CRLF & _ "Japanese Symbols and Punctuation" & @CRLF & _ "Unicode code points regex: [\x3000-\x303F]" & @CRLF & _ "Regex: ([、-〿])" & @CRLF & _ "" & @CRLF & _ "、 。 〃 〄 々 〆 〇 〈 〉 《 》 「 」 『 』 【 】 〒 〓 〔 〕 〖 〗 〘 〙 〚 〛 〜 〝 〞 〟 〠 〡 〢 〣 〤 〥 〦 〧 〨 〩 〪 〫 〬 〭 〮 〯 〰 〱 〲 〳 〴 〵 〶 〷 〸 〹 〺 〻 〼 〽 〾 〿" & @CRLF & _ "---------------------------------------------------------" & @CRLF & _ "Miscellaneous Japanese Symbols and Characters" & @CRLF & _ "Unicode code points regex: ([\x31F0-\x31FF\x3220-\x3243\x3280-\x337F])" & @CRLF & _ "Regex: ([ㇰ-ㇿ㈠-㉃㊀-㍿])" & @CRLF & _ "" & @CRLF & _ "ㇰ ㇱ ㇲ ㇳ ㇴ ㇵ ㇶ ㇷ ㇸ ㇹ ㇺ ㇻ ㇼ ㇽ ㇾ ㇿ" & @CRLF & _ "㈠ ㈡ ㈢ ㈣ ㈤ ㈥ ㈦ ㈧ ㈨ ㈩ ㈪ ㈫ ㈬ ㈭ ㈮ ㈯ ㈰ ㈱ ㈲ ㈳ ㈴ ㈵ ㈶ ㈷ ㈸ ㈹ ㈺ ㈻ ㈼ ㈽ ㈾ ㈿ ㉀ ㉁ ㉂ ㉃" & @CRLF & _ "㊀ ㊁ ㊂ ㊃ ㊄ ㊅ ㊆ ㊇ ㊈ ㊉ ㊊ ㊋ ㊌ ㊍ ㊎ ㊏ ㊐ ㊑ ㊒ ㊓ ㊔ ㊕ ㊖ ㊗ ㊘ ㊙ ㊚ ㊛ ㊜ ㊝ ㊞ ㊟ ㊠ ㊡ ㊢ ㊣ ㊤ ㊥ ㊦ ㊧ ㊨ ㊩ ㊪ ㊫ ㊬ ㊭ ㊮ ㊯ ㊰ ㊱ ㊲ ㊳ ㊴ ㊵ ㊶ ㊷ ㊸ ㊹ ㊺ ㊻ ㊼ ㊽ ㊾ ㊿" & @CRLF & _ "㋀ ㋁ ㋂ ㋃ ㋄ ㋅ ㋆ ㋇ ㋈ ㋉ ㋊ ㋋ ㋐ ㋑ ㋒ ㋓ ㋔ ㋕ ㋖ ㋗ ㋘ ㋙ ㋚ ㋛ ㋜ ㋝ ㋞ ㋟ ㋠ ㋡ ㋢ ㋣ ㋤ ㋥ ㋦ ㋧ ㋨ ㋩ ㋪ ㋫ ㋬ ㋭ ㋮ ㋯ ㋰ ㋱ ㋲ ㋳ ㋴ ㋵ ㋶ ㋷ ㋸ ㋹ ㋺ ㋻ ㋼ ㋽ ㋾" & @CRLF & _ "㌀ ㌁ ㌂ ㌃ ㌄ ㌅ ㌆ ㌇ ㌈ ㌉ ㌊ ㌋ ㌌ ㌍ ㌎ ㌏ ㌐ ㌑ ㌒ ㌓ ㌔ ㌕ ㌖ ㌗ ㌘ ㌙ ㌚ ㌛ ㌜ ㌝ ㌞ ㌟ ㌠ ㌡ ㌢ ㌣ ㌤ ㌥ ㌦ ㌧ ㌨ ㌩ ㌪ ㌫ ㌬ ㌭ ㌮ ㌯ ㌰ ㌱ ㌲ ㌳ ㌴ ㌵ ㌶ ㌷ ㌸ ㌹ ㌺ ㌻ ㌼ ㌽ ㌾ ㌿ ㍀ ㍁ ㍂ ㍃ ㍄ ㍅ ㍆ ㍇ ㍈ ㍉ ㍊ ㍋ ㍌ ㍍ ㍎ ㍏ ㍐ ㍑ ㍒ ㍓ ㍔ ㍕ ㍖ ㍗ ㍘ ㍙ ㍚ ㍛ ㍜ ㍝ ㍞ ㍟ ㍠ ㍡ ㍢ ㍣ ㍤ ㍥ ㍦ ㍧ ㍨ ㍩ ㍪ ㍫ ㍬ ㍭ ㍮ ㍯ ㍰ ㍱ ㍲ ㍳ ㍴ ㍵ ㍶ ㍻ ㍼ ㍽ ㍾ ㍿" & @CRLF & _ "---------------------------------------------------------" & @CRLF & _ "Alphanumeric and Punctuation (Full Width)" & @CRLF & _ "Unicode code points regex: [\xFF01-\xFF5E]" & @CRLF & _ "Regex: ([!-~])" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ?" & @CRLF & _ "@ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _" & @CRLF & _ "` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~" & @CRLF & _ "---------------------------------------------------------" & @CRLF & _ " " & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH) Local $aFullArray[0] For $i = 0 To UBound($aArray) -1 _ArrayConcatenate($aFullArray, $aArray[$i]) Next $aArray = $aFullArray ; Present the entire match result _ArrayDisplay($aArray, "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 AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm