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
No Match

/
/
g

Test String

Code Generator

Generated Code

const regex = /[^.]+[^ ]/g; // Alternative syntax using RegExp constructor // const regex = new RegExp('[^.]+[^ ]', 'g') const str = `Recent studies have described a pattern associated with specific object (e.g., face-related and building-related) in human occipito-temporal cortex. However, it is as yet unclear to what extent this selectivity is due to differences in the statistics of local object features present in the different object categories, and to what extent it reflects holistic grouping processes operating across the entire object image. To resolve this question it is essential to use images in which identical sets of local features elicit the perception of different object categories. The classic Rubin vase–face illusion provides an excellent experimental set to test this question. In the illusion, the same local contours lead to the perception of different objects (vase or face). Here we employed a modified Rubin vase–face illusion to explore to what extent the activation in face-related regions is attributable to the presence of local face features, or is due to a more holistic grouping process that involves the entire face figure. Biasing cues (gratings and color) were used to control the perceptual state of the observer. We found enhanced activation in face-related regions during the ‘face profile’ perceptual state compared to the ‘vase’ perceptual state. Control images ruled out the involvement of the biasing cues in the effect. Thus, object-selective activation in human face-related regions entails global grouping processes that go beyond the local processing of stimulus features. Neural analysis of the visual scene in early visual areas is inherently local. The receptive fields of neurons in these areas are relatively small and sensitive to local edges and contours. Yet visual perception of objects is global and unified. This transformation requires grouping processes by which local features have to be ‘‘assigned’’ to a particular figure (e.g., Ullman, 1996; Marr, 1982). Surprisingly little physiological evidence has been obtained that directly explores the neural correlates of such perceptual phenomena (but see recent single-unit recording works by Zhou, Friedman, & von Der Heydt, 2000; Lee, Mumford, Romero, & Lamme, 1998; Zipser, Lamme & Schiller, 1996; Lamme, 1995). Recently, a substantial number of neuroimaging studies have found that human lateral occipital and occipito-temporal cortex is sensitive to images of objects compared to a variety of textures and noise patterns (Kourtzi & Kanwisher, 2000a; Grill-Spector et al., 1999; Ishai, Ungerleider, Martin, Schouten, & Haxby, 1999; Malach et al., 1995). Furthermore, subdivisions of occipito-temporal cortex have been reported to show segregation according to specific object categories. Prominent examples are areas selective tive for faces (Haxby, Hoffman, & Gobbini, 2000; Tong, Nakayama, Moscovitch, Weinrib, & Kanwisher, 2000; Halgren et al., 1999; Kanwisher, Chun, McDermott, & Ledden, 1996) and buildings (Aguirre, Zarahn, & D’Esposito, 1998; Epstein & Kanwisher, 1998) as well as other object categories (Ishai et al., 1999). It is generally assumed that such category-specific organization necessarily implies a holistic representation that goes beyond local features. Indeed, high-order object representations do show remarkably abstract characteristics such as substantial size and position invariance (Grill-Spector et al., 1999), and invariance to the visual cues used to define objects (Gilaie Dotan, Ullman, Kushnir, Steinberg, & Malach, 2000; Kourtzi & Kanwisher, 2000a; Grill-Spector, Kushnir, Edelman, Itzchak, & Malach, 1998). Nevertheless, selective activation to one set of objects relative to another can still be explained by differences in the distribution of local object elements or features. To appreciate this point, consider a small aperture that samples local parts of an object, such as a tumbler or a face (Figure 1A and B). It is rather straightforward to see that although the sampling from the two images is strictly local, the aggregate distributions of local object features that can be obtained from the two object categories are substantially different and thus could provide the basis for the observed object selectivity.`; // Reset `lastIndex` if this regex is defined globally // regex.lastIndex = 0; let m; while ((m = regex.exec(str)) !== null) { // This is necessary to avoid infinite loops with zero-width matches if (m.index === regex.lastIndex) { regex.lastIndex++; } // The result can be accessed through the `m`-variable. m.forEach((match, groupIndex) => { console.log(`Found match, group ${groupIndex}: ${match}`); }); }

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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions