Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • Update Regex
    ctrl+⇧+s
  • Save new Regex
    ctrl+s
  • Add to Community Library

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

/
/
gm

Test String

Code Generator

Generated Code

using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"(?:""text"":\s*\{\s*""ja_JP"":\s*""|\G(?<=\\n))([^""]*?)(?:""|\\n)"; string input = @"""textList"": [ { ""id"": 4, ""name"": ""modeselect"", ""folder"": true, ""children"": [ { ""id"": 13, ""name"": ""Motion"", ""fontId"": 6, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""Motion"" }, ""folder"": false }, { ""id"": 12, ""name"": ""Story"", ""fontId"": 7, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""Story"" }, ""folder"": false }, { ""id"": 11, ""name"": ""Main_Character"", ""fontId"": 6, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""Main Character"" }, ""folder"": false }, { ""id"": 5, ""name"": ""Mode_select"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""Mode Select"" }, ""folder"": false }, { ""id"": 24, ""name"": ""Story_Mode"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""Story Mode"" }, ""folder"": false }, { ""id"": 25, ""name"": ""Battle_Mode"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""Battle Mode"" }, ""folder"": false }, { ""id"": 8297, ""name"": ""Dictionary"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""Dictionary"" }, ""folder"": false }, { ""id"": 46, ""name"": ""Z_desition"", ""fontId"": 9, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""Z key:OK\nC key:Back"" }, ""folder"": false }, { ""id"": 47, ""name"": ""back_to_the_title"", ""fontId"": 9, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": "" Back to the title?"" }, ""folder"": false }, { ""id"": 51, ""name"": ""select_mode"", ""fontId"": 9, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": "" Select Mode"" }, ""folder"": false }, { ""id"": 8298, ""name"": ""Go_to_the_Story_Mode"", ""fontId"": 9, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""Go to the Story Mode?"" }, ""folder"": false }, { ""id"": 8299, ""name"": ""Go_to_the_Battle_Mode"", ""fontId"": 9, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""Go to the Battle Mode?"" }, ""folder"": false }, { ""id"": 8300, ""name"": ""Go_to_the_Dictionary"", ""fontId"": 9, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""Go to the Dictionary?"" }, ""folder"": false }, { ""id"": 48, ""name"": ""ok"", ""fontId"": 8, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""OK"" }, ""folder"": false }, { ""id"": 49, ""name"": ""cancel"", ""fontId"": 8, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""Cancel"" }, ""folder"": false }, { ""id"": 7, ""name"": ""Story_outline"", ""fontId"": 9, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""自由奔放で傲慢な魔族\nであるアストリア。\nアストリアは最近\n地上に住まう種族の\n殲滅に勤しんでいた。\n次第に恐怖と畏れから\n地上に住まう者達に名が\n知れ渡り始めていた。\nある日、アストリアの\n元に面倒事が\n持ち込まれる・・・"" }, ""folder"": false }, { ""id"": 6, ""name"": ""character_name"", ""folder"": true, ""children"": [ { ""id"": 8, ""name"": ""Astoria"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": "" Astoria"" }, ""folder"": false }, { ""id"": 19, ""name"": ""Test2_name"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": "" Test2"" }, ""folder"": false }, { ""id"": 20, ""name"": ""Test3_name"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": "" Test3"" }, ""folder"": false }, { ""id"": 21, ""name"": ""Test4_name"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": "" Test4"" }, ""folder"": false }, { ""id"": 22, ""name"": ""Test5_name"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": "" Test5"" }, ""folder"": false }, { ""id"": 23, ""name"": ""Test6_name"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": "" Test6"" }, ""folder"": false } ] }, { ""id"": 9, ""name"": ""story_name"", ""folder"": true, ""children"": [ { ""id"": 10, ""name"": ""Story1_name"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""1. 魔族娘の自由旅"" }, ""folder"": false }, { ""id"": 14, ""name"": ""Story2_name"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""2. "" }, ""folder"": false }, { ""id"": 15, ""name"": ""Story3_name"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""3. "" }, ""folder"": false }, { ""id"": 16, ""name"": ""Story4_name"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""4. "" }, ""folder"": false }, { ""id"": 17, ""name"": ""Story5_name"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""5. "" }, ""folder"": false }, { ""id"": 18, ""name"": ""Story6_name"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""6. "" }, ""folder"": false } ] } ] }, { ""id"": 26, ""name"": ""stageselect"", ""folder"": true, ""children"": [ { ""id"": 31, ""name"": ""Stage_select"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""Stage Select"" }, ""folder"": false }, { ""id"": 32, ""name"": ""GameStart"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""Game Start"" }, ""folder"": false }, { ""id"": 33, ""name"": ""Enemy_Character"", ""fontId"": 6, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""Enemy Character"" }, ""folder"": false }, { ""id"": 50, ""name"": ""back_to_the_modeselect"", ""fontId"": 9, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""Back to the Mode Select?"" }, ""folder"": false }, { ""id"": 27, ""name"": ""character_name_stage"", ""folder"": true, ""children"": [ { ""id"": 34, ""name"": ""Leonor"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": "" Leonor"" }, ""folder"": false }, { ""id"": 35, ""name"": ""Riz"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": "" Riz"" }, ""folder"": false }, { ""id"": 36, ""name"": ""Mary"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": "" Mary"" }, ""folder"": false }, { ""id"": 37, ""name"": ""Koyo"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": "" Koyo"" }, ""folder"": false }, { ""id"": 38, ""name"": ""Beryl"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": "" Beryl"" }, ""folder"": false }, { ""id"": 39, ""name"": ""Amelia"", ""fontId"": 5, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": "" Amelia"" }, ""folder"": false } ] }, { ""id"": 28, ""name"": ""stage_outline"", ""folder"": true, ""children"": [ { ""id"": 979, ""name"": ""stage1_outline"", ""fontId"": 9, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""アストリアは日課である\n種族の殲滅を終わらせて\n城で休息を取っていた。\nそんな時、何者かが城に\n侵入した事を察知する。\n急ぎ様子を見に行くと\nそこには興味深そうに\n城を見渡す堕天使の\nレオノールが居た・・・"" }, ""folder"": false }, { ""id"": 980, ""name"": ""stage2_outline"", ""fontId"": 9, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""レオノールから\n聞き出した情報を頼りに\n妖狐を探していた。\nその最中、魔族のリズが\n道の真ん中で風景画を\n描いているのを見かける\n興味本位で声を掛け\n描いている絵を見せて\nもらったのだが・・・"" }, ""folder"": false }, { ""id"": 981, ""name"": ""stage3_outline"", ""fontId"": 9, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""ジメジメと湿った空気が\n充満している薄暗い\n森の中を進んでいると\n奇妙な帽子を被った\n魔女のメアリーが\nアストリアの前に\n立ち塞がる。\n妖狐の差し金で\nアストリアの邪魔を\nしようとするが・・・"" }, ""folder"": false }, { ""id"": 982, ""name"": ""stage4_outline"", ""fontId"": 9, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""森を抜けた先に\n古びた神社を見つけた\nアストリア。\n中から九つの白い尾を\n持った妖狐の狐耀が\n現れる。\nアストリアと狐耀は\n自身の主張を通すべく\n力尽くで相手を屈服\nさせようとする・・・"" }, ""folder"": false }, { ""id"": 983, ""name"": ""stage5_outline"", ""fontId"": 9, ""letterSpacing"": 0, ""lineSpacing"": 0, ""text"": { ""ja_JP"": ""面倒事を終わらせて\n気が晴れたアストリアに\n竜人種のベリルが声を\n掛けてくる。\nアストリアが狐耀を\n倒したことに対して\nベリルは感謝を示す。\nどうでも良い\nアストリアは休むべく\n帰ろうとするが・・・"" }, ""folder"": false"; RegexOptions options = RegexOptions.Multiline; foreach (Match m in Regex.Matches(input, pattern, options)) { Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index); } } }

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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx