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

/
/
g

Test String

Code Generator

Generated Code

$re = '/EGA-(?:(?!New=).)+(New=[:\d\/ ]+)/'; $str = 'structure(list(flight_history_id = c(280604281L, 280316415L, 280315758L, 280316495L, 280303866L, 280303866L, 280271465L, 280271465L, 280271465L, 280271465L), date_time_recorded = structure(c(10L, 4L, 3L, 2L, 7L, 1L, 9L, 8L, 6L, 5L), .Label = c("2012-11-12 05:50:23.547-08", "2012-11-12 15:38:10.099-08", "2012-11-12 16:10:06.968-08", "2012-11-12 17:25:08.814-08", "2012-11-12 17:58:14.268-08", "2012-11-13 05:16:41.01-08", "2012-11-13 06:51:45.831-08", "2012-11-13 07:38:19.593-08", "2012-11-13 07:54:22.588-08", "2012-11-13 17:55:58.673-08" ), class = "factor"), event = structure(c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Arrival Estimation", "Time Adjustment" ), class = "factor"), data_updated = structure(c(3L, 8L, 7L, 4L, 2L, 5L, 1L, 10L, 9L, 6L), .Label = c("AGD- New=11/13/12 10:22, EGA- Old=11/13/12 11:20 New=11/13/12 11:09", "AGD- Old=11/13/12 07:40 New=11/13/12 07:38, EGA- Old=11/13/12 10:25 New=11/13/12 10:18", "EGA- Based on Distance and Airspeed", "EGD- New=11/13/12 06:35, DGATE- New=A1, EGA- New=11/13/12 07:15", "EGD- New=11/13/12 07:45, DGATE- New=11, EGA- New=11/13/12 10:25, AGATE- New=A1", "EGD- New=11/13/12 08:55, EGA- New=11/13/12 09:45, AGATE- New=A1", "EGD- New=11/13/12 19:05, DGATE- New=A7, EGA- New=11/13/12 20:50, AGATE- New=C5", "EGD- New=11/13/12 20:20, DGATE- New=A1, EGA- New=11/13/12 21:00", "EGD- Old=11/13/12 08:55 New=11/13/12 10:05, EGA- Old=11/13/12 09:45 New=11/13/12 10:55", "EGD- Old=11/13/12 10:05 New=11/13/12 10:30, EGA- Old=11/13/12 10:55 New=11/13/12 11:20" ), class = "factor")), .Names = c("flight_history_id", "date_time_recorded", "event", "data_updated"), row.names = c(862L, 5514L, 5527L, 5539L, 5545L, 5558L, 5564L, 5566L, 5570L, 5572L), class = "data.frame")'; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 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