Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
Sponsors
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
Processing...

Test String

Substitution
Processing...

Code Generator

Generated Code

#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox Local $sRegex = "(?m)^(.*?)\[(.*?)(\(.*?\).*?)\]$" Local $sString = "### **UPSC Related Key Points and Key Facts**" & @CRLF & _ "" & @CRLF & _ "---" & @CRLF & _ "" & @CRLF & _ "#### **1. Background and Formation of Jharkhand**" & @CRLF & _ "- **Carved Out of Bihar:**" & @CRLF & _ " - Formed on **November 15, 2000**, during PM Atal Bihari Vajpayee's tenure. " & @CRLF & _ " - Alongside Chhattisgarh (from Madhya Pradesh) and Uttarakhand (from Uttar Pradesh). " & @CRLF & _ " - Created to address tribal and regional aspirations, coinciding with **Birsa Munda's birth anniversary.**" & @CRLF & _ "" & @CRLF & _ "- **Structure Post-Bifurcation:**" & @CRLF & _ " - Comprises **18 of Bihar’s 55 districts.**" & @CRLF & _ " - Has **81 Assembly seats** and **14 Lok Sabha seats.**" & @CRLF & _ " - Rich in mineral resources, but socioeconomically underdeveloped." & @CRLF & _ "" & @CRLF & _ "- **Historical Demand:**" & @CRLF & _ " - Tribal leader **Jaipal Singh Munda’s Jharkhand Party** fought for a separate state post-Independence. " & @CRLF & _ " - Demand was initially rejected by the **States Reorganisation Commission** citing economic and agricultural concerns." & @CRLF & _ "" & @CRLF & _ "---" & @CRLF & _ "" & @CRLF & _ "#### **2. Political Landscape and Turmoil**" & @CRLF & _ "- **Dominant Parties:**" & @CRLF & _ " - **BJP** and **Jharkhand Mukti Morcha (JMM)** dominate state politics. " & @CRLF & _ " - Other players: Congress, RJD, CPI, and **Jharkhand Vikas Morcha-Prajatantrik (JVM-P)** (formed by Babulal Marandi)." & @CRLF & _ "" & @CRLF & _ "- **Chief Ministers:**" & @CRLF & _ " - Jharkhand has had **seven CMs** since 2000, reflecting political instability. " & @CRLF & _ " - Only **Raghubar Das** (BJP, 2014-2019) completed a full term. " & @CRLF & _ "" & @CRLF & _ "---" & @CRLF & _ "" & @CRLF & _ "#### **3. Electoral and Political History**" & @CRLF & _ "- **2000-2005: Early Instability**" & @CRLF & _ " - **Babulal Marandi (BJP):** First CM, but infighting led to his replacement by **Arjun Munda (BJP)** in 2003." & @CRLF & _ " - In 2005, JMM leader **Shibu Soren** briefly became CM but resigned within 10 days due to lack of majority." & @CRLF & _ "" & @CRLF & _ "- **2006-2014: Turmoil and Alliances**" & @CRLF & _ " - **Madhu Koda (Independent):** Became CM in 2006 but lost power after corruption allegations. " & @CRLF & _ " - Frequent switches between Presidents' Rule and short-lived alliances involving BJP, JMM, Congress, and Independents. " & @CRLF & _ " - **Hemant Soren (JMM):** Became CM in 2013 for the first time after breaking with BJP." & @CRLF & _ "" & @CRLF & _ "- **2014-2019: BJP Consolidation**" & @CRLF & _ " - **Raghubar Das (BJP):** First non-tribal CM, completed a five-year term." & @CRLF & _ " - BJP’s 2014 Assembly win was driven by the **Narendra Modi wave.**" & @CRLF & _ "" & @CRLF & _ "- **2019-Present: JMM Resurgence**" & @CRLF & _ " - **Hemant Soren (JMM):** Returned as CM after JMM-Congress alliance secured a majority. " & @CRLF & _ " - Accusations of corruption led to his temporary resignation; **Champai Soren** served briefly as CM." & @CRLF & _ "" & @CRLF & _ "---" & @CRLF & _ "" & @CRLF & _ "#### **4. Challenges in Jharkhand’s Politics**" & @CRLF & _ "- **Fragmentation and Alliances:**" & @CRLF & _ " - No single party has won a clear majority in any Assembly election so far." & @CRLF & _ " - Frequent changes in government due to defections and coalition instability." & @CRLF & _ "" & @CRLF & _ "- **Tribal vs Non-Tribal Leadership:**" & @CRLF & _ " - Tribal leaders (Babulal Marandi, Hemant Soren) dominate discourse, but BJP experimented with a non-tribal CM in Raghubar Das." & @CRLF & _ "" & @CRLF & _ "- **Corruption and Governance Issues:**" & @CRLF & _ " - Several leaders, including Madhu Koda and Hemant Soren, have faced allegations of corruption." & @CRLF & _ " - Political instability has hindered long-term development." & @CRLF & _ "" & @CRLF & _ "---" & @CRLF & _ "" & @CRLF & _ "#### **5. Current Political Scenario**" & @CRLF & _ "- **BJP:**" & @CRLF & _ " - Led by **Babulal Marandi**, who returned to BJP in 2019 after leading JVM-P. " & @CRLF & _ " - Raghubar Das now serves as Governor of Odisha." & @CRLF & _ "" & @CRLF & _ "- **JMM:**" & @CRLF & _ " - Hemant Soren continues to lead despite controversies, but internal rifts remain a concern. " & @CRLF & _ " - Competing demands from tribal and non-tribal sections persist." & @CRLF & _ "" & @CRLF & _ "---" & @CRLF & _ "" & @CRLF & _ "### **Mermaid Diagram**" & @CRLF & _ "" & @CRLF & _ "```mermaid" & @CRLF & _ "graph LR" & @CRLF & _ "A[Formation of Jharkhand (2000)] --> B[Reasons for Creation]" & @CRLF & _ "B --> B1[Tribal Aspirations]" & @CRLF & _ "B --> B2[Birsa Munda Legacy]" & @CRLF & _ "B --> B3[Rich Mineral Resources]" & @CRLF & _ "" & @CRLF & _ "A --> C[Political Landscape]" & @CRLF & _ "C --> C1[BJP Dominance]" & @CRLF & _ "C --> C2[JMM as Key Rival]" & @CRLF & _ "C --> C3[Congress and Regional Players]" & @CRLF & _ "" & @CRLF & _ "A --> D[Timeline of Chief Ministers]" & @CRLF & _ "D --> D1[Babulal Marandi (2000-2003)]" & @CRLF & _ "D --> D2[Arjun Munda (2003-2005, 2010-2013)]" & @CRLF & _ "D --> D3[Madhu Koda (2006-2008)]" & @CRLF & _ "D --> D4[Hemant Soren (2013-Present)]" & @CRLF & _ "" & @CRLF & _ "A --> E[Challenges]" & @CRLF & _ "E --> E1[Frequent Political Instability]" & @CRLF & _ "E --> E2[Corruption Allegations]" & @CRLF & _ "E --> E3[Tribal vs Non-Tribal Leadership]" & @CRLF & _ "" & @CRLF & _ "A --> F[Recent Developments]" & @CRLF & _ "F --> F1[Babulal Marandi Returns to BJP]" & @CRLF & _ "F --> F2[Hemant Soren Faces Corruption Allegations]" & @CRLF & _ "F --> F3[Tribal Discontent and Economic Challenges]" & @CRLF & _ "``` " & @CRLF & _ "" Local $sSubst = "\1\[\"\2\3\"]" Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst) MsgBox($MB_SYSTEMMODAL, "Result", $sResult)

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