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 = /void\s*\*\s*([0-9a-zA-Z\_]*)\s*\[\s*\]\s*\[[0-9a-zA-Z_]*\]\s*=\s*\{(.*?)\}\s*;/m str = '/** * Link\\\'s eyes and mouth textures are placed at the exact same place in adult and child Link\\\'s respective object files. * This allows the array to only contain the symbols for one file and have it apply to both. This is a problem for * shiftability, and changes will need to be made in the code to account for this in a modding scenario. The symbols * from adult Link\\\'s object are used here. */ #ifndef AVOID_UB void* sEyeTextures[PLAYER_EYES_MAX] = { gLinkAdultEyesOpenTex, // PLAYER_EYES_OPEN gLinkAdultEyesHalfTex, // PLAYER_EYES_HALF gLinkAdultEyesClosedfTex, // PLAYER_EYES_CLOSED gLinkAdultEyesLeftTex, // PLAYER_EYES_LEFT gLinkAdultEyesRightTex, // PLAYER_EYES_RIGHT gLinkAdultEyesWideTex, // PLAYER_EYES_WIDE gLinkAdultEyesDownTex, // PLAYER_EYES_DOWN gLinkAdultEyesWincingTex, // PLAYER_EYES_WINCING }; void* sMouthTextures[PLAYER_MOUTH_MAX] = { gLinkAdultMouthClosedTex, // PLAYER_MOUTH_CLOSED gLinkAdultMouthHalfTex, // PLAYER_MOUTH_HALF gLinkAdultMouthOpenTex, // PLAYER_MOUTH_OPEN gLinkAdultMouthSmileTex, // PLAYER_MOUTH_SMILE }; #else // Defining `AVOID_UB` will use a 2D array instead and properly use the child link pointers to allow for shifting. void* sEyeTextures[][PLAYER_EYES_MAX] = { { gLinkAdultEyesOpenTex, // PLAYER_EYES_OPEN gLinkAdultEyesHalfTex, // PLAYER_EYES_HALF gLinkAdultEyesClosedfTex, // PLAYER_EYES_CLOSED gLinkAdultEyesLeftTex, // PLAYER_EYES_LEFT gLinkAdultEyesRightTex, // PLAYER_EYES_RIGHT gLinkAdultEyesWideTex, // PLAYER_EYES_WIDE gLinkAdultEyesDownTex, // PLAYER_EYES_DOWN gLinkAdultEyesWincingTex, // PLAYER_EYES_WINCING }, { gLinkChildEyesOpenTex, // PLAYER_EYES_OPEN gLinkChildEyesHalfTex, // PLAYER_EYES_HALF gLinkChildEyesClosedfTex, // PLAYER_EYES_CLOSED gLinkChildEyesLeftTex, // PLAYER_EYES_LEFT gLinkChildEyesRightTex, // PLAYER_EYES_RIGHT gLinkChildEyesWideTex, // PLAYER_EYES_WIDE gLinkChildEyesDownTex, // PLAYER_EYES_DOWN gLinkChildEyesWincingTex, // PLAYER_EYES_WINCING }, }; void* sMouthTextures[][PLAYER_MOUTH_MAX] = { { gLinkAdultMouthClosedTex, // PLAYER_MOUTH_CLOSED gLinkAdultMouthHalfTex, // PLAYER_MOUTH_HALF gLinkAdultMouthOpenTex, // PLAYER_MOUTH_OPEN gLinkAdultMouthSmileTex, // PLAYER_MOUTH_SMILE }, { gLinkChildMouthClosedTex, // PLAYER_MOUTH_CLOSED gLinkChildMouthHalfTex, // PLAYER_MOUTH_HALF gLinkChildMouthOpenTex, // PLAYER_MOUTH_OPEN gLinkChildMouthSmileTex, // PLAYER_MOUTH_SMILE }, }; #endif Color_RGB8 sTunicColors[PLAYER_TUNIC_MAX] = { { 30, 105, 27 }, // PLAYER_TUNIC_KOKIRI { 100, 20, 0 }, // PLAYER_TUNIC_GORON { 0, 60, 100 }, // PLAYER_TUNIC_ZORA }; Color_RGB8 sGauntletColors[] = { { 255, 255, 255 }, { 254, 207, 15 }, }; Gfx* sBootDListGroups[][2] = { { gLinkAdultLeftIronBootDL, gLinkAdultRightIronBootDL }, // PLAYER_BOOTS_IRON { gLinkAdultLeftHoverBootDL, gLinkAdultRightHoverBootDL }, // PLAYER_BOOTS_HOVER }; ' # Print the match result str.scan(re) do |match| puts match.to_s end

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