Regular Expressions 101

Save & Share

  • Regex Version: ver. 245
  • 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
No Match

r'
'
gm

Test String

Code Generator

Generated Code

# coding=utf8 # the above tag defines encoding for this document and is for Python 2.x compatibility import re regex = r'(?<=(?:"[^"]*?"\s*,\s*)|"question":\s*\[\s*))"([^"]*)"' test_str = ("[\n" " {\n" " \"questionsList\": [\n" " \"정밀 동맥경화 협착도 검사(Segment ABI+TBI+PWV)는 어떤 환자에게 진행되나요?\",\n" " \"정밀 동맥경화 협착도 검사(Segment ABI+TBI+PWV) 시 약이나 식사는 어떻게 해야 하나요?\",\n" " \"정밀 동맥경화 협착도 검사(Segment ABI+TBI+PWV)는 어디에서 진행되나요?\",\n" " \"안저촬영(Fundus photography, both)은 어떤 상태를 검사하는 기본 정밀검사인가요?\",\n" " \"안저촬영(Fundus photography, both)으로 알 수 있는 질환은 무엇인가요?\",\n" " \"안저촬영(Fundus photography, both)은 어디에서 진행되나요?\",\n" " \"자율신경계 이상 검사(HRV) 전에 자제해야 하는 것은 무엇인가요?\",\n" " \"자율신경계 이상 검사(HRV)는 어디에서 진행되나요?\",\n" " \"말초신경병증 검사는 어떤 질병에 의한 신경 손상 정도를 알아보는 검사인가요?\",\n" " \"말초신경병증 검사는 어디에서 진행되나요?\",\n" " \"갑상선 세침흡입검사 전에 해야 할 일은 무엇인가요?\",\n" " \"갑상선 세침흡입검사의 성공 가능성은 어느 정도인가요?\",\n" " \"갑상선 세침흡입검사 시 어떤 옷을 입지 않도록 교육해야 하나요?\",\n" " \"갑상선 세침흡입검사는 어디에서 진행되나요?\",\n" " \"갑상선 초음파 검사 시 환자에게 어떤 설명을 해야 하나요?\",\n" " \"갑상선 초음파 검사 시 어떤 옷을 입지 않도록 교육해야 하나요?\",\n" " \"갑상선 초음파 검사는 어디에서 진행되나요?\",\n" " \"CGMS (Continuous glucose monitoring, 연속혈당측정장치)는 무엇을 측정하는 장치인가요?\",\n" " \"CGMS (Continuous glucose monitoring, 연속혈당측정장치)의 적응증은 무엇인가요?\",\n" " \"CGMS (Continuous glucose monitoring, 연속혈당측정장치)의 장점은 무엇인가요?\",\n" " \"CGMS (Continuous glucose monitoring, 연속혈당측정장치)의 단점은 무엇인가요?\",\n" " \"CGMS (Continuous glucose monitoring, 연속혈당측정장치) 사용 시 동의서가 필요한가요?\",\n" " \"CGMS (Continuous glucose monitoring, 연속혈당측정장치) 사용 시 주의사항은 무엇인가요?\",\n" " \"덱스콤 G7의 센서 사용 기간은 얼마인가요?\",\n" " \"덱스콤 G7의 센서는 어디에 부착하나요?\",\n" " \"덱스콤 G7 사용 시 본인 소유 스마트폰이 없을 경우 어떻게 해야 하나요?\",\n" " \"덱스콤 G7 사용 시 와이파이를 끊으면 안되나요?\",\n" " \"ipro-retro(레트로) 센서의 사용 시간은 얼마인가요?\",\n" " \"ipro-retro(레트로) 사용 시 혈당 기록은 어떻게 해야 하나요?\",\n" " \"ipro-retro(레트로) 센서 제거는 어디에서 해야 하나요?\",\n" " \"리브레 센서의 사용 기간은 얼마인가요?\",\n" " \"리브레 센서는 어디에 부착하나요?\",\n" " \"리브레 앱으로 혈당 확인 시 무엇을 확인할 수 있나요?\",\n" " \"리브레 센서 제거 후 어떻게 처리해야 하나요?\",\n" " \"리브레 센서 부착된 팔에 혈압 측정이 금기인가요?\"\n" " ]\n" " }\n" "]") matches = re.finditer(regex, test_str, re.MULTILINE) for matchNum, match in enumerate(matches, start=1): print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group())) for groupNum in range(0, len(match.groups())): groupNum = groupNum + 1 print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum))) # Note: for Python 2.7 compatibility, use ur'' to prefix the regex and u"" to prefix the test string and substitution.

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 Python, please visit: https://docs.python.org/3/library/re.html