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

re = /(magnolia\.develop)(s*=s*)(.+)/ str = '#-------------------------------------------- # Here we define some properties not # configured in the config repository. # They are used in common before the initialization # of the repositories. # # WARNING: on Windows systems, either use the / # to separate path elements, or escape the \\ with # another \\, i.e C:\\\\magnolia\\\\data\\\\repositories # or c:/magnolia/data/repositories #-------------------------------------------- magnolia.home=${magnolia.app.rootdir} # The directory to expose file system resources from magnolia.resources.dir=${magnolia.home} # Pattern to define which resources should be observed by ClasspathScanner magnolia.resources.classpath.observation.pattern=.*\\\\.(ftl|yaml)$ # Directories relative to magnolia.resources.dir which will be excluded from FileResourceOrigin observation. # Also see info.magnolia.resourceloader.file.FileSystemResourceOrigin#EXCLUDED_DIRECTORIES #magnolia.resources.filesystem.observation.excludedDirectories=META-INF,WEB-INF,cache,docroot,logs,repositories,tmp magnolia.cache.startdir=${magnolia.home}/cache magnolia.upload.tmpdir=${magnolia.home}/tmp magnolia.exchange.history=${magnolia.home}/history magnolia.repositories.config=WEB-INF/config/default/repositories.xml magnolia.repositories.home=${magnolia.home}/repositories magnolia.repositories.jackrabbit.config=WEB-INF/config/repo-conf/jackrabbit-bundle-derby-search.xml log4j.config=WEB-INF/config/default/log4j.xml magnolia.logs.dir=${magnolia.home}/logs # The directories in which the bootstrap files are searched magnolia.bootstrap.dir=WEB-INF/bootstrap/author WEB-INF/bootstrap/common # This is only used for the initial installation afterward the configuration in the config repository is used # The value is saved in /server/admin magnolia.bootstrap.authorInstance=true # Some modules contain optional sample content. They will check this property to decide if they should install # the sample data magnolia.bootstrap.samples=true # Activate UTF-8 support to pages magnolia.utf8.enabled=false # Switch to false to enhance the performance of the javascript generation and similar magnolia.develop=false # Change to point at your custom Vaadin widgetset and theme # Your widgetset should always inherit magnolia\'s default widgetset (info.magnolia.widgetset.MagnoliaWidgetSet) # Your theme should always include magnolia\'s default theme (admincentral) magnolia.ui.vaadin.widgetset=info.magnolia.widgetset.MagnoliaWidgetSet magnolia.ui.vaadin.theme=admincentral # Contact details displayed in the footer of the login form #magnolia.service.contact= #-------------------------------------------- # Repository connection #-------------------------------------------- magnolia.connection.jcr.userId = admin magnolia.connection.jcr.password = admin # Set it to true if bootstrapping/update should be performed automatically magnolia.update.auto=false # Location of the file containing both the private and the public keys used to verify authenticity of activation requests # This file is generated if not present magnolia.author.key.location=${magnolia.home}/WEB-INF/config/default/magnolia-activation-keypair.properties ' subst = '$1$2true' result = str.sub(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