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

Code Generator

Generated Code

$re = '/(whore)|(masturbate)|(dildo)|(fuck)|(hooker)|(sex)|(blowjob)|(cock)|(anal\s)|(pussy)|(jizz)|(twat)|(busty)|(slut)/'; $str = 'We continue with our 13th series of Evening Talks. Thursday 27th October 2016 Bob House. How you think is more important than what you know. Would you think that an educational approach that does not aim to impart specific content, but rather to develop thinking skills, would be a good approach to 21st century learning? Philosophy for Children (P4C) is just such an approach. It bases teaching and learning on philosophical enquiry and questioning. Bob House, former CEO SAPERE, will explain how it works and what its impact is, especially on children from disadvantaged backgrounds. SAPERE is a charity that trains 4,000 UK teachers a year in adopting P4C. http://www.sapere.org.uk/ Tuesday 29th November 2016 Michael Schluter. Economics, Relationships and Creating a Just Society. Should we organise our family and social relationships to serve the interest of the economy, or organise the economy to serve the interests of just and stable relationships? If the latter, what changes need to be made in the area of business and finance to achieve the relational outcomes we desire? www.relational-analytics.com Wednesday 18th January 2017 Intermission Youth Theatre perform Verona Road. Romeo and Juliet love each other but their families’ war over postcodes may tear them apart. Based on Shakespeare’s \'Romeo and Juliet\', \'Verona Road\' tackles gang culture, postcode rivalry and peer pressure. http://www.intermissionyouththeatre.co.uk/ Tuesday 7th February 2017 Henry Wigan & Alex Pitt. Why Impact Wins. Mustard Seed is an impact venture capital firm that seeks to solve some of the world\'s biggest social and environmental problems. It has backed the likes of What3Words: a global address system for the 4bn unaddressed, and Winnow Solutions: a technology company that seeks to reduce the 1 trillion dollars of food wasted annually. Mustard Seed believes that by investing in the most innovative impact ventures it can in fact generate higher, rather than lower economic returns for investors. http://mustardseedimpact.com/ Thursday 23rd March 2017 Charles Wookey & Laura Turkington. Is “Business Purpose” a fad or the future? Can a focus on purpose help reconnect business and society? Charles Wookey, CEO of Blueprint for Better Business and Laura Turkington from Vodafone will explore some challenges and opportunities. www.blueprintforbusiness.org The talks will be held at 37 Fleet Street. Talks are preceded by drinks from 6pm for a 6.45pm start. The talk and questions take less than an hour, with plenty of opportunity for informal discussion afterwards. If you would like to attend any of the events please contact Petina Trevett on 020 7353 4522 or events@hoaresbank.co.uk stating which event(s) you would like to come to. www.hoaresbank.co.uk events@hoaresbank.co.uk You have opted in for event email invitations. You may opt-out from receiving details of events at any time. If you wish to do this, please click here. ________________________________________ C. Hoare & Co. is authorised by the Prudential Regulation Authority (PRA) and regulated by the Financial Conduct Authority (FCA) and the Prudential Regulation Authority with firm reference number 122093. The FCA’s address is 25 The North Colonnade, Canary Wharf, London E14 5HS. C. Hoare & Co. is registered in England no. 240822. Registered office 37 Fleet St, London EC4P 4DQ. This message and attachments are confidential, and are sent for the personal attention of the addressee(s). If you are not the intended recipient, any use, disclosure or copying of this document is unauthorised. Information transmitted by email may be intercepted, lost, destroyed, corrupted or delayed and as a result, C. Hoare & Co. does not accept responsibility for any errors or omissions in the content of this message. If the content of this message is of a personal nature, the email will have been sent in a personal capacity and not on behalf of C. Hoare & Co.. C. Hoare & Co. may monitor all incoming and outgoing emails in line with current legislation. Although emails are screened for viruses, C. Hoare & Co. cannot guarantee that any transmissions will be virus free. ________________________________________ '; preg_match($re, $str, $matches, PREG_OFFSET_CAPTURE, 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