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

Code Generator

Generated Code

$re = '/^(?P<key>[^#]\S+) ?= ?"(?P<value>.+)"$/m'; $str = '.encoding = "UTF-8" bios.bootorder = "hdd,cdrom" checkpoint.vmstate = "" cleanshutdown = "TRUE" config.version = "8" displayname = "generic-ubuntu1804-vmware" ehci.pcislotnumber = "-1" ehci.present = "FALSE" extendedconfigfile = "generic-ubuntu1804-vmware.vmxf" floppy0.present = "FALSE" guestos = "ubuntu-64" guestos.detailed.data = "bitness=\'64\' distroName=\'Ubuntu\' distroVersion=\'18.04\' familyName=\'Linux\' kernelVersion=\'4.15.0-76-generic\' prettyName=\'Ubuntu 18.04.4 LTS\'" gui.fullscreenatpoweron = "FALSE" gui.viewmodeatpoweron = "windowed" hgfs.linkrootshare = "TRUE" hgfs.maprootshare = "TRUE" ide0:0.clientdevice = "TRUE" ide0:0.devicetype = "cdrom-raw" ide0:0.filename = "auto detect" ide0:0.present = "TRUE" isolation.tools.hgfs.disable = "FALSE" memsize = "2048" monitor.phys_bits_used = "42" msg.autoanswer = "true" numa.autosize.cookie = "20001" numa.autosize.vcpu.maxpervirtualnode = "2" numvcpus = "2" nvme0.present = "FALSE" nvram = "generic-ubuntu1804-vmware.nvram" parallel0.autodetect = "FALSE" parallel0.bidirectional = "" parallel0.filename = "" parallel0.present = "FALSE" parallel0.startconnected = "FALSE" pcibridge0.pcislotnumber = "17" pcibridge0.present = "TRUE" pcibridge4.functions = "8" pcibridge4.pcislotnumber = "21" pcibridge4.present = "TRUE" pcibridge4.virtualdev = "pcieRootPort" pcibridge5.functions = "8" pcibridge5.pcislotnumber = "22" pcibridge5.present = "TRUE" pcibridge5.virtualdev = "pcieRootPort" pcibridge6.functions = "8" pcibridge6.pcislotnumber = "23" pcibridge6.present = "TRUE" pcibridge6.virtualdev = "pcieRootPort" pcibridge7.functions = "8" pcibridge7.pcislotnumber = "24" pcibridge7.present = "TRUE" pcibridge7.virtualdev = "pcieRootPort" powertype.poweroff = "soft" powertype.poweron = "soft" powertype.reset = "soft" powertype.suspend = "soft" proxyapps.publishtohost = "FALSE" remotedisplay.vnc.enabled = "FALSE" remotedisplay.vnc.ip = "127.0.0.1" remotedisplay.vnc.port = "5904" replay.filename = "" replay.supported = "FALSE" sata0.present = "FALSE" scsi0.pcislotnumber = "16" scsi0.present = "TRUE" scsi0.virtualdev = "lsilogic" scsi0:0.filename = "generic-ubuntu1804-vmware.vmdk" scsi0:0.present = "TRUE" scsi0:0.redo = "" serial0.autodetect = "FALSE" serial0.filename = "" serial0.filetype = "" serial0.pipe.endpoint = "" serial0.present = "FALSE" serial0.startconnected = "FALSE" serial0.trynorxloss = "" serial0.yieldonmsrread = "" softpoweroff = "FALSE" sound.autodetect = "TRUE" sound.filename = "-1" sound.present = "FALSE" sound.startconnected = "FALSE" svga.guestbackedprimaryaware = "TRUE" svga.vramsize = "134217728" tools.synctime = "TRUE" tools.upgrade.policy = "upgradeAtPowerCycle" toolsinstallmanager.updatecounter = "1" usb.pcislotnumber = "-1" usb.present = "FALSE" uuid.action = "create" uuid.bios = "56 4d fc 04 54 ab 8e 06-3c c5 a6 4d f9 c8 bc 5a" uuid.location = "56 4d fc 04 54 ab 8e 06-3c c5 a6 4d f9 c8 bc 5a" virtualhw.productcompatibility = "hosted" virtualhw.version = "12" vmci0.id = "1861462628" vmci0.pcislotnumber = "35" vmci0.present = "TRUE" vmotion.checkpointfbsize = "134217728" vmotion.checkpointsvgaprimarysize = "134217728" '; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); // Print the entire match result var_dump($matches);

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 PHP, please visit: http://php.net/manual/en/ref.pcre.php