Regular Expressions 101

Save & Manage Regex

  • Current Version: 3
  • 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]
  • Character class intersection
    [\w&&[^\d]]
  • 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

import re regex = re.compile(r"(\d+\.\s)") test_str = ("Curious about what's in store for you? Tap into the wisdom of the cosmos now by reading your daily horoscope! 🔮\n" "Want to know what the universe has planned for you? Uncover your celestial forecast by clicking here! 🌠\n" "Feel the pulse of the planets! Dive into your daily horoscope now - the stars are waiting to guide you! 🌟\n" "Align with the stars! Discover the cosmic insights tailored to you by reading your daily horoscope here! 🌌\n" "The secrets of your day are written in the stars. Dare to discover them? Click here for your daily horoscope! ✨\n" "Your zodiac sign holds the key to your day. Unlock its secrets now by reading your daily horoscope here! 🗝️\n" "What do the stars have to say about your destiny today? Find out by clicking here for your daily horoscope! 🌠\n" "Embrace your celestial journey! Navigate your day with confidence by reading your daily horoscope here! 🌌\n" "1. Navigate your cosmic pathway! Tap here to explore your daily horoscope. 🌌\n" "2. Embrace the mysteries of the universe. Uncover your daily horoscope now! 🔮\n" "3. Are you ready to align with the stars? Click here to decode your daily horoscope! 🌠\n" "4. Wondering what the stars have in store for you? Find out by reading your daily horoscope! 🌟\n" "5. Your day, decoded by the stars! Click here to access your daily horoscope. 🌞\n" "6. Illuminate your path with the wisdom of the cosmos! Read your daily horoscope here! ✨\n" "7. Make the most of your day with stellar guidance! Check out your daily horoscope now! 🌌\n" "8. Unlock the secrets of the skies! Click here to explore your daily horoscope. 🌠\n" "9. Chart your course with the stars! Read your daily horoscope now! 🌟\n" "10. Explore the mysteries of the cosmos. Check out your daily horoscope here! 🌌\n" "11. Ready to step into your destiny? Click here to discover your daily horoscope! 🔮\n" "12. Let the stars be your guide. Uncover your daily horoscope now! 🌠\n" "13. Your celestial journey begins here! Dive into your daily horoscope! 🌞\n" "14. Unleash the power of the zodiac! Discover your daily horoscope here! 🌟\n" "15. Embark on your stellar journey! Tap here for your daily horoscope! 🌌\n" "16. Want to know what the cosmos has in store for you? Find out with your daily horoscope! 🌠\n" "17. The stars hold the key to your day! Unlock it with your daily horoscope! 🔑\n" "18. Take a cosmic snapshot of your day! Check out your daily horoscope here! 🌟\n" "19. Set your course by the stars! Click here to access your daily horoscope! 🌌\n" "20. Navigate the celestial winds! Discover your daily horoscope now! 🌠\n" "21. Your stars, your story! Dive into your daily horoscope here! 🌞\n" "22. Unveil the cosmic curtain! Find out what's in store with your daily horoscope! 🌟\n" "23. The cosmos is calling! Answer with your daily horoscope! 🌌\n" "24. The universe has a message for you! Decode it with your daily horoscope! 🔮\n" "25. Let the planets plot your path! Click here to read your daily horoscope! 🌠\n" "26. The cosmos whispers wisdom to you! Listen by reading your daily horoscope! 🌞\n" "27. Unlock the cosmic code of your day! Check your daily horoscope here! 🌟\n" "28. What does the celestial sphere hold for you? Find out with your daily horoscope! 🌌\n" "29. The secrets of the stars await you! Unveil them with your daily horoscope! 🔮\n" "30. Chart your celestial journey! Click here for your daily horoscope! 🌠\n" "31. Read the stellar script of your day! Access your daily horoscope now! 🌞\n" "32. The zodiac holds the keys to your day. Unlock them with your daily horoscope! 🌟\n" "33. The stars are waiting to guide you! Discover their secrets with your daily horoscope! 🌌\n" "34. What do the heavens have in store for you? Find out by checking your daily horoscope! 🔮\n" "35. Walk your stellar path with confidence! Click here for your daily horoscope! 🌠\n" "36. Uncover the cosmic clues to your day! Read your daily horoscope here! 🌞\n" "37. Let the celestial sphere guide you! Access your daily horoscope now! 🌟\n" "38. Hear the whispers of the cosmos! Click here to explore your daily horoscope! 🌌\n" "39. Want to know what the universe whispers? Discover it with your daily horoscope! 🔮\n" "40. Discover the stellar symphony of your day! Click here for your daily horoscope! 🌠\n" "41. Navigate the zodiac with the stars as your guide! Read your daily horoscope now! 🌞\n" "42. Want a cosmic forecast of your day? Click here to discover your daily horoscope! 🌟\n" "43. What celestial secrets does your day hold? Uncover them with your daily horoscope! 🌌\n" "44. Step into the cosmos! Click here to access your daily horoscope! 🔮\n" "45. Unveil your stellar story! Discover your daily horoscope here! 🌠\n" "46. Curious about the celestial forecast for your day? Find out with your daily horoscope! 🌞\n" "47. Let the cosmos be your guide! Dive into your daily horoscope here! 🌟\n" "48. The stars have a message for you! Decode it with your daily horoscope! 🌌\n" "49. What secrets do the stars hold for you? Find out with your daily horoscope! 🔮\n" "50. Embark on a cosmic journey! Explore your daily horoscope here! 🌠") matches = regex.finditer(test_str) for match_num, match in enumerate(matches, start=1): print(f"Match {match_num} was found at {match.start()}-{match.end()}: {match.group()}") for group_num, group in enumerate(match.groups(), start=1): print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")

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 Python, please visit: https://docs.python.org/3/library/re.html