Regular Expressions 101

Save & Manage Regex

  • Current Version: 2
  • 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
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 = /([\d]+\/[\d\w]+)?\s?([\w]+\/[\w\d]+)\s((?:[\w]{1}[\d]{4}\s[\w]{1}[\d]{5}\s\-\s)+[\w]{1}[\d]{4}\s[\w]{1}[\d]{5})/m str = 'FVAK21PAWU_1801072135 Page 1 FVAK21 PAWU 080632 VAAAK1 VA ADVISORY DTG: 20180108/0630Z VAAC: ANCHORAGE VOLCANO: KLYUCHEVSKOY 300260 PSN: N5603 E16038 AREA: KAMCHATKA PENINSULA SUMMIT ELEV: 15863 FT (4835 M) ADVISORY NR: 2018/044 RMK: PLEASE SEE FVFE01 RJTD ISSUED BY TOKYO VAAC WHICH DESCRIBES CONDITIONS NEAR THE ANCHORAGE VAAC AREA OF RESPONSIBILITY BH JAN 2018 AAWU VA ADVISORY DTG: 20100101/1500Z VAAC: LONDON VOLCANO: ORAEFAJOKULL 374010 PSN: N6400 W01639 AREA: ICELAND SUMMIT ELEV: 2119M ADVISORY NR: 2010/002 INFO SOURCE: IMO AVIATION COLOUR CODE: RED ERUPTION DETAILS: OBS ASH PLUME, EST 12KM FROM RADAR. OBS VA DTG: 10/1500Z OBS VA CLD: 10/2100Z SFC/FL200 N6329 W01651 - N6517 W01614 - N6849 E00351 - N6742 E01549 - N6329 W01651 FCST VA CLD +6HR: 10/2100Z SFC/FL200 N6329 W01651 - N6517 W01614 - N6849 E00351 - N6742 E01549 - N6329 W01651 FL200/350 N6327 W01656 - N6600 W01444 - N6750 W00307 - N6854 E01550 - N6718 E01833 - N6327 W01656 FL350/550 N6325 W01635 - N6450 W01625 - N6812 W00004 - N6841 E01441 - N6726 E01653 - N6325 W01635 FCST VA CLD +12HR: 11/0300Z SFC/FL200 N6334 W01640 - N6526 W01629 - N6945 E00502 - N6658 E03036 - N6327 E03908 - N6629 E00931 - N6334 W01640 FL200/350 N6329 W01701 - N6556 W01624 - N7009 E00806 - N6431 E04310 - N6026 E04358 - N6709 E00854 - N6329 W01701 FL350/550 N6334 W01650 - N6551 W01547 - N6931 E01235 - N6439 E03929 - N6128 E04027 - N6634 E01013 - N6334 W01650 FCST VA CLD +18HR: 11/0900Z SFC/FL200 N6327 W01717 - N6517 W01706 - N6905 E00017 - N6949 E02107 - N6024 E05301 - N5804 E05147 - N6630 E01612 - N6327 W01717 FL200/350 N6327 W01645 - N6556 W01613 - N7054 E01405 - N5925 E05658 - N5421 E04829 - N6717 E01018 - N6327 W01645 FL350/550 N6327 W01634 - N6634 W01510 - N7012 E01458 - N5953 E05349 - N5558 E04930 - N6630 E01405 - N6327 W01634 RMK: ASH PLUME NOW OBS, ESTIMATED HEIGHT 12KM FROM RADAR. INCREASING SEISMIC ACTIVITY. NXT ADVISORY: WILL BE ISSUED BY 20150210/1800Z = DTG: 20211228/0015Z VAAC: BUENOS AIRES VOLCANO: SABANCAYA 354006 PSN: S1547 W07150 AREA: PERU SUMMIT ELEV: 19576 FT (5967 M) ADVISORY NR: 2021/1507 INFO SOURCE: GOES-E. GFS. WEBCAM. VOLCAT. AVIATION COLOUR CODE: NOT GIVEN ERUPTION DETAILS: CONTINUOUS EMISSION OBS VA DTG: 27/2340Z OBS VA CLD: SFC/FL240 S1532 W07159 - S1540 W07149 - S1547 W07150 - S1550 W07202 - S1540 W07208 - S1532 W07159 MOV NW 10KT FCST VA CLD +6 HR: 28/0530Z SFC/FL240 S1537 W07159 - S1544 W07151 - S1547 W07150 - S1552 W07202 - S1543 W07208 - S1537 W07159 FCST VA CLD +12 HR: 28/1130Z SFC/FL240 S1531 W07202 - S1540 W07152 - S1547 W07150 - S1554 W07202 - S1543 W07213 - S1531 W07202 FCST VA CLD +18 HR: 28/1730Z SFC/FL240 S1532 W07211 - S1538 W07155 - S1547 W07151 - S1552 W07203 - S1546 W07218 - S1532 W07211 RMK: VA IS HARDLY DETECTED IN STLT IMAGERY DUE A WEAK EMISSION AND SOME WX CLD IN THE AREA. WEBCAMS SHOWS CONT EMS OF STEAM AND VA ...SMN NXT ADVISORY: WILL BE ISSUED BY 20211228/0615Z=' # Print the match result str.scan(re) do |match| puts match.to_s end

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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html