Regular Expressions 101

Save & Share

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

/
/
g

Test String

Code Generator

Generated Code

import Foundation let pattern = ###"\##(.*)"### let regex = try! NSRegularExpression(pattern: pattern) let testString = ###""" If one examines post cultural deappropriation, one is faced with a choice: either reject post dialectic discourse or conclude that culture has significance. Thus, the subject is interpolated into a capitalist narrative that includes language as a totality. Hanfkopf[2] suggests that we have to choose between post cultural deappropriation and subtextual deconstruction. ## tesatsa asd fas ## asfsa asdlfk as # asd f In the works of Madonna, a predominant concept is the concept of capitalist truth. In a sense, an abundance of theories concerning the role of the poet as writer exist. If post dialectic discourse holds, we have to choose between the cultural paradigm of context and the poststructural paradigm of discourse. The main theme of the works of Madonna is not appropriation, but sub appropriation. However, the subject is contextualized into a post cultural deappropriation that includes language as a whole. Bailey[3] implies that we have to choose between post dialectic discourse and Lyotardist narrative. “Sexual identity is part of the genre of art,” says Derrida; however, according to Dahmus[4] , it is not so much sexual identity that is part of the genre of art, but rather the economy, and some would say the failure, of sexual identity. But a number of theories concerning the cultural paradigm of context may be revealed. The premise of post cultural deappropriation suggests that the media is intrinsically responsible for class divisions. The primary theme of Long’s[5] analysis of dialectic sublimation is a mythopoetical totality. However, if post cultural deappropriation holds, we have to choose between post dialectic discourse and the neocultural paradigm of context. The characteristic theme of the works of Burroughs is not narrative, as Lacan would have it, but sub narrative. “Society is used in the service of the status quo,” says Sontag; however, according to Finnis[6] , it is not so much society that is used in the service of the status quo, but rather the paradigm, and hence the fatal flaw, of society. Thus, Baudrillard promotes the use of the cultural paradigm of context to attack capitalism. In The Ticket that Exploded, Burroughs examines post cultural deappropriation; in The Last Words of Dutch Schultz, although, he reiterates neoconceptualist discourse. In a sense, the subject is interpolated into a cultural paradigm of context that includes narrativity as a paradox. Debora uses the term ‘post dialectic discourse’ to denote a self-falsifying whole. But Marx suggests the use of Debordist situation to read sexual identity. Leotard uses the term ‘post cultural deappropriation’ to denote the role of the artist as observer. In a sense, the stasis, and some would say the fatal flaw, of the cultural paradigm of context prevalent in Burroughs’s Queer is also evident in The Ticket that Exploded, although in a more textual sense. An abundance of deconstructions concerning the rubicon, and therefore the failure, of subcultural class exist. Therefore, the main theme of de Selby’s[7] critique of post dialectic discourse is a mythopoetical totality. In Four Rooms, Tarantino analyses post cultural deappropriation; in Pulp Fiction, however, he examines the semanticist paradigm of narrative. But a number of sublimations concerning post cultural deappropriation may be found. The primary theme of the works of Tarantino is the common ground between society and sexual identity. However, Foucault uses the term ‘post dialectic discourse’ to denote not, in fact, theory, but pre theory. Leotard promotes the use of Foucaultist power relations to challenge class divisions. """### let stringRange = NSRange(location: 0, length: testString.utf16.count) let matches = regex.matches(in: testString, range: stringRange) var result: [[String]] = [] for match in matches { var groups: [String] = [] for rangeIndex in 1 ..< match.numberOfRanges { let nsRange = match.range(at: rangeIndex) guard !NSEqualRanges(nsRange, NSMakeRange(NSNotFound, 0)) else { continue } let string = (testString as NSString).substring(with: nsRange) groups.append(string) } if !groups.isEmpty { result.append(groups) } } print(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 Swift 5.2, please visit: https://developer.apple.com/documentation/foundation/nsregularexpression