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
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
Processing...

Test String

Substitution
Processing...

Code Generator

Generated Code

re = /^\s*@(?<param>\S+)(?<dtwhitespace>\s*)\/\*##DATATYPE\((?>lhapp_owner\.)?(?<datatype>[^)]+)[^ ,]+(?<outparam>\s*OUT)?(?<comma>,?)(?<paramwhitespace>\s*)?(?<paramdoc>--##PARAM @.*)$/m str = ' @nInventoryPackID /*##DATATYPE(inventorypack.inventorypackid)<*/INT/*>##*/, --##PARAM @nInventoryPackID The ID of the inventory pack to be reclassifyed @sInventoryPackNo /*##DATATYPE(inventorypack.inventorypackno)<*/NVARCHAR(254)/*>##*/, --##PARAM @sInventoryPackNo The inventory pack number to be reclassifyed (for logging) @nQuantity /*##DATATYPE(inventorypack.quantity)<*/FLOAT/*>##*/, --##PARAM @nQuantity Quantity on the original pack @nNewPartID /*##DATATYPE(inventorypack.partid)<*/INT/*>##*/, --##PARAM @nNewPartID ID of th epart associated with the new pack @sNewInventoryPackNo /*##DATATYPE(inventorypack.inventorypackno)<*/NVARCHAR(254)/*>##*/, --##PARAM @sreclassifyInventoryPackNo The new reclassifyed inventory pack number @nNewInventoryStateID /*##DATATYPE(invstate.invstateid)<*/SMALLINT/*>##*/, --##PARAM @nreclassifyInventoryStateID The state of the new pack @nNewLocationID /*##DATATYPE(inventorypack.locationid)<*/INT/*>##*/, --##PARAM @nNewLocationID The location of the reclassified pack @sFIFONumber /*##DATATYPE(inventorypack.fifonumber)<*/NVARCHAR(254)/*>##*/, --##PARAM @sFIFONumber the fifo number @nLabelRequired /*##DATATYPE(settingsdatatype.datatypetinyint)<*/TINYINT/*>##*/, --##PARAM @nLabelRequired flag to indicate if a label is required to be printed @nPrinterID /*##DATATYPE(lkmachinestageprinter.printerid)<*/TINYINT/*>##*/, --##PARAM @nPrinterID ID of the printer for a label @nNewQuantity /*##DATATYPE(inventorypack.quantity)<*/FLOAT/*>##*/, --##PARAM @nNewQuantity Quantity on the new pack @sComments /*##DATATYPE(comments.comments)<*/NVARCHAR(2000)/*>##*/, --##PARAM @sComments any comments for the new pack @dOpenedDT /*##DATATYPE(inventorypack_.openeddt)<*/DATETIMEOFFSET/*>##*/, --##PARAM @dOpenedDT DATETIMEOFFSET the form was opened @dModifiedDT /*##DATATYPE(settingsdatatype.datatypetimestamp)<*/DATETIMEOFFSET/*>##*/, --##PARAM @dModifiedDT The current plant date/time @nLoginID /*##DATATYPE(lhapp_owner.auditlog.loginid)<*/SMALLINT/*>##*/, --##PARAM @nLoginID The loginID of the user logged on causing this call (1 if via Udi) @nSessionID /*##DATATYPE(lhapp_owner.auditlog.lhsessionid)<*/INT/*>##*/, --##PARAM @nSessionID The IE session ID of the user\'s log on @nPlantID /*##DATATYPE(lhapp_owner.auditlog.plantid)<*/SMALLINT/*>##*/, --##PARAM @nPlantID The plant ID (used for filtering the audit) @nLangID /*##DATATYPE(lhapp_owner.login.rflanguageid)<*/SMALLINT/*>##*/, --##PARAM @nLangID The language ID to report any errors in @nEntityTransactionLogID /*##DATATYPE(entitytransactionlog.entitytransactionlogid)<*/INT/*>##*/ OUT, --##PARAM @nEntityTransactionLogID The ID of the created entitytransactionlog entry @nParentEntityTransactionLogID /*##DATATYPE(entitytransactionlog.entitytransactionlogid)<*/INT/*>##*/ --##PARAM @nParentEntityTransactionLogID The ID of the entitytransactionlogs parent ' subst = '\\t${param}${dtwhitespace}IN${outparam}\\t\\t${datatype}%TYPE${comma}${paramwhitespace}${paramdoc}' 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