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

Substitution

Processing...

Code Generator

Generated Code

re = /bugid.*\n(.*)/m str = 'bugid = 461 comment#461 = drop-cap position for hanging, jutting, etc bugid = 466 comment#466 = Positioning printouts on the page bugid = 480 comment#480 = Being able to *switch* items in the Distribute/Align menu bugid = 492 comment#492 = Footnotes which stay on the same page as the associated word bugid = 498 comment#498 = Typography Preference Settings as part of Paragraph Styles bugid = 502 comment#502 = Multiselection in items Overview bugid = 504 comment#504 = We need more accuray object selection bugid = 505 comment#505 = Object sellection with Ctrl bugid = 533 comment#533 = move objects in the object-tree bugid = 555 comment#555 = rotating objects without rotate-cursor ? bugid = 575 comment#575 = (in general multiple application of properties) bugid = 577 comment#577 = Paragraph Styles -> Kerning and language options missing bugid = 579 comment#579 = right-click paragraph, save as paragraph style bugid = 689 comment#689 = basepoint of lines cannot be set to the middle or diagonal one bugid = 835 comment#835 = Measurement attachment to the guides and frames bugid = 889 comment#889 = inverse bezier tool handling bugid = 950 comment#950 = The search and replace dialogue should not be modal because the way it is now you cannot cut and paste into it. bugid = 990 comment#990 = Mail-Merge bugid = 1008 comment#1008 = ? bugid = 1032 comment#1032 = Request: PDF Bookmarks at arbritrary locations within text frames. bugid = 1034 comment#1034 = Edit Paste disabled after copy from another program, but Control V works bugid = 1037 comment#1037 = GetTextLength returns 0 for non-empty frame bugid = 1069 comment#1069 = Auto-adjust size of text box to the text bugid = 1085 comment#1085 = Better text on path control bugid = 1086 comment#1086 = Lines styles with two or more parallel lines bugid = 1094 comment#1094 = Importing multipage PDFs must give options for importing a selection of pages see also 1352 (dup) bugid = 1118 comment#1118 = Give instant access to Style editor from within the Properties palette>Text bugid = 1212 comment#1212 = styles for drop caps bugid = 1321 comment#1321 = Individual DPI settings bugid = 1398 comment#1398 = Improve memory efficiency of raster image export bugid = 1406 comment#1406 = Add text metrics to scripter bugid = 1410 comment#1410 = Allow automatic text frames after document has been started bugid = 1423 comment#1423 = Single key-stroke to kern letters... bugid = 1462 comment#1462 = Lines (borders) on frames are drawn from the center of the edge to the outside bugid = 1463 comment#1463 = Add pdf export "templates" bugid = 1474 comment#1474 = RTF Import bugid = 1475 comment#1475 = Bad hyphenating implementation bugid = 1518 comment#1518 = PrefsTable breaks if indexing is started from (1,0) bugid = 1540 comment#1540 = Issue with stylesheet and emphasis like italic or bold fonts bugid = 1569 comment#1569 = regression from 1.2 bugid = 1592 comment#1592 = New textframes not linkable to "Autoframes" bugid = 1598 comment#1598 = - assigned Missing preference to text importer bugid = 1622 comment#1622 = Splitting the import menu bugid = 1627 comment#1627 = improvement for handling changes in images on disc bugid = 1629 comment#1629 = A need to run menu items from the scriptor for automation purposes bugid = 1630 comment#1630 = A macro recorder to build a script automatically from users actions. bugid = 1663 comment#1663 = ability to assign shortcut keys to the running of a script bugid = 1671 comment#1671 = - needs testing bugid = 1678 comment#1678 = Search in Picture Management should search user specified directory list, pick up all matching images in dir. bugid = 2264 comment#2264 = - Support more PDF/X-x versions bugid = 2460 comment#2460 = - Support JDF' subst = '\\1\\n' result = str.gsub(re, subst) # Print the result of the substitution puts 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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html