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
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
  • Match everything enclosed
    (?:...)
  • Capture everything enclosed
    (...)
  • 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

/
/

Test String

Code Generator

Generated Code

const regex = /(author\s=\s\{+(.*)+\},)/; // Alternative syntax using RegExp constructor // const regex = new RegExp('(author\\s=\\s\\{+(.*)+\\},)', '') const str = `@article{Cian2014, abstract = {The aim of the present study was to investigate (1) the relative contribution of the egocentric reference as well as body orientation perception to visual horizon percept during tilt or during increased gravito-inertial acceleration (GiA, hypergravity environment) conditions and (2) the role of vestibular signals in the inter-individual differences observed in these perceptual modalities. Perceptual estimates analysis showed that backward tilt induced (1) an elevation of the visual horizon, (2) an elevation of the egocentric estimation (visual straight ahead) and (3) an overestimation of body tilt. The increase in the magnitude of GiA induced (1) a lowering of the apparent horizon, (2) a lowering of the straight ahead and (3) a perception of backward tilt. Overall, visual horizon percept can be expressed as the combination of body orientation perception and egocentric estimation. When assessing otolith reactivity using off-vertical axis rotation (OVAR), only visual egocentric estimation was significantly correlated with horizontal OVAR performance. On the one hand, we found a correlation between a low modulation amplitude of the otolith responses and straight ahead accuracy when the head axis was tilted relative to gravity. On the other hand, the bias of otolith responses was significantly correlated with straight ahead accuracy when subjects were submitted to an increase in the GiA. Thus, straight ahead sense would be dependent to some extent to otolith function. These results are discussed in terms of the contribution of otolith inputs in the overall multimodal integration subtending spatial constancy.}, author = { Cian, C and Barraud, P A and Paillard, A C and Hidot, S and Denise, P and Ventre-Dominey, J }, doi = {10.1007/s00221-013-3816-6}, issn = {1432-1106}, journal = {Experimental brain research}, keywords = {Adult,Eye Movements,Eye Movements: physiology,Female,Gravitation,Humans,Individuality,Male,Orientation,Orientation: physiology,Otolithic Membrane,Otolithic Membrane: physiology,Psychophysics,Reflex, Vestibulo-Ocular,Rotation,Statistics as Topic,Young Adult}, month = mar, number = {3}, pages = {1037--45}, pmid = {24430025}, title = {{Otolith signals contribute to inter-individual differences in the perception of gravity-centered space.}}, url = {http://www.ncbi.nlm.nih.gov/pubmed/24430025}, volume = {232}, year = {2014} } @article{Cian2014, abstract = {The aim of the present study was to investigate (1) the relative contribution of the egocentric reference as well as body orientation perception to visual horizon percept during tilt or during increased gravito-inertial acceleration (GiA, hypergravity environment) conditions and (2) the role of vestibular signals in the inter-individual differences observed in these perceptual modalities. Perceptual estimates analysis showed that backward tilt induced (1) an elevation of the visual horizon, (2) an elevation of the egocentric estimation (visual straight ahead) and (3) an overestimation of body tilt. The increase in the magnitude of GiA induced (1) a lowering of the apparent horizon, (2) a lowering of the straight ahead and (3) a perception of backward tilt. Overall, visual horizon percept can be expressed as the combination of body orientation perception and egocentric estimation. When assessing otolith reactivity using off-vertical axis rotation (OVAR), only visual egocentric estimation was significantly correlated with horizontal OVAR performance. On the one hand, we found a correlation between a low modulation amplitude of the otolith responses and straight ahead accuracy when the head axis was tilted relative to gravity. On the other hand, the bias of otolith responses was significantly correlated with straight ahead accuracy when subjects were submitted to an increase in the GiA. Thus, straight ahead sense would be dependent to some extent to otolith function. These results are discussed in terms of the contribution of otolith inputs in the overall multimodal integration subtending spatial constancy.}, author = { Cian, C and Barraud, P A and Paillard, A C and Hidot, S and Denise, P and Ventre-Dominey, J }, doi = {10.1007/s00221-013-3816-6}, issn = {1432-1106}, journal = {Experimental brain research}, keywords = {Adult,Eye Movements,Eye Movements: physiology,Female,Gravitation,Humans,Individuality,Male,Orientation,Orientation: physiology,Otolithic Membrane,Otolithic Membrane: physiology,Psychophysics,Reflex, Vestibulo-Ocular,Rotation,Statistics as Topic,Young Adult}, month = mar, number = {3}, pages = {1037--45}, pmid = {24430025}, title = {{Otolith signals contribute to inter-individual differences in the perception of gravity-centered space.}}, url = {http://www.ncbi.nlm.nih.gov/pubmed/24430025}, volume = {232}, year = {2014} }`; let m; if ((m = regex.exec(str)) !== null) { // 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