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

Code Generator

Generated Code

$re = '/(?<date>(?<=Date:\* ).+?(?=\n))|(?<duration>(?<=Duration:\* ).+?(?= s\n))|(?<callerid>(?<=1: \").+?(?=\" <))|(?<caller>(?<=<).+?(?=>\n2))|(?<dialed>(?<=2: ).+?(?=\n))|(?<confidence>(?<=Confidence:\* ).+?(?=\n))|(?<trans>(?<=TimeDurationSpeakerPhrase\n)((.|\n)*)\n\*DISC)| /m'; $str = 'Hello, This email contains the transcription of the following call: *Date:* 2023-01-20 13:15:11 *Duration:* 124 s *Speakers:* 1: "[V] RCR MURRIETA CA" <444555444> 2: 5554443333 *Locale:* en-US *Confidence:* 84.2% Transcription TimeDurationSpeakerPhrase 13:15:11 5 s 2 thank you for calling the rapid clean restoration please hold while we connect your call 13:15:22 14 s 2 no 13:15:29 2 s 1 i 13:15:39 0 s 2 Hello. 13:15:42 2 s 1 Uh, hi, is this rapid clean restoration? 13:15:45 0 s 2 Yes. 13:15:46 5 s 1 hi uhm do you serve i believe you\'re here in marietta correct do you service marietta 13:15:52 1 s 2 Yes. 13:15:54 6 s 1 OK. I\'m just looking for the person who, well, makes decisions about community outreach or marketing. Would that be you? 13:16:00 1 s 2 Uh, yes. 13:16:02 13 s 1 awesome uhm i just wanted to introduce myself i\'m a publisher and i have a magazine that actually focuses on the west marietta community so i believe that\'s really close to your location um we\'re talking copper canyon bear creek la cresta and a few others 13:16:16 16 s 1 um and we also pair that up with a digital platform to help promote your business in the area and i\'m wondering if i could just schedule some time with you to review what i do and how the magazine helps connect your business with the community do you perhaps have some time maybe next week 13:16:32 7 s 2 uh if i don\'t leave a lot of time to talk but i want to tell you something in an email that has pricing and layouts and stuff like that i\'ll take a look at it 13:16:41 2 s 1 OK, uh, what\'s your e-mail? 13:16:43 3 s 2 Uh, you sent it to Nathan at rapid clean restoration. 13:16:55 0 s 2 Yes. 13:16:56 14 s 1 OK, perfect. Nathan. Um, I\'ll send you something over. It\'s best to meet or even do a virtual presentation. There\'s just so many options. I can\'t put that all out into an e-mail, but um, I\'ll kind of give you the basics of where it starts and then, you know, we can certainly work from there. 13:17:11 1 s 2 OK. Thank you. 13:17:12 1 s 1 all right thank you nathan bye bye *DISCOVER OUR FULL RANGE OF BENEFITS* Bring Your Own Device Contract-Free and Pay-as-You-Go Exceptional Compatibility Friendly, Available Support Staff Keep Your Current Number U.S./Canada Enhanced 911 [image: facebook] <https://www.facebook.com/VoIP.ms/> [image: twitter] <https://t.sidekickopen14.com/s3t/c/5/f18dQhb0V1-gmb8cpgc1W14p09m59hl3kW7_k2841CX6NGN36PYBbwdMX6W56JXy755nn4Rf197v5Y04?te=W3R5hFj4cm2zwW4fQ47l4fGCmnW3Fbt5S4kHSlC3b7c2&si=8000000022317663&pi=00185947-b53b-4e80-fbd0-482f43cad100> [image: linkedin] <https://t.sidekickopen14.com/s3t/c/5/f18dQhb0V1-gmb8cpgc1W14p09m59hl3kW7_k2841CX6NGN36PYBbwdMX6W56JXy755nn4Rf197v5Y04?te=W3R5hFj4cm2zwW4mKLS-3ZWVWBW3K2-zv1JxwY5W1Lw3rh45LM6yW1LF-s945l5lZ1V3&si=8000000022317663&pi=00185947-b53b-4e80-fbd0-482f43cad100> [image: youtube] <https://t.sidekickopen14.com/s3t/c/5/f18dQhb0V1-gmb8cpgc1W14p09m59hl3kW7_k2841CX6NGN36PYBbwdMX6W56JXy755nn4Rf197v5Y04?te=W3R5hFj4cm2zwW4mKLS-4rCvX6W4hCVj23Fbt5SW4kHSlC3_ZzS1F3M2m0LS5QQ1&si=8000000022317663&pi=00185947-b53b-4e80-fbd0-482f43cad100> *Note:* Do not reply to this email, you will not receive a response. You can contact us regarding this update by sending an email to support@voip.ms.'; 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