Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • 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{1,2}-\d{3} \d{3})(.*)(\(.*)/'; $str = '643 Ручка FM-104 032 Сr глянцевый/кристалл (50) 3818 Ручка FS-043 160 Cr глянцев/ярко белая 9010 (18) 3993 Ручка FS-071 128 PCP матовый/St светлый (50) 8673 Ручка FS-043 160 Cr глянцев/эм.фарфор 9001(18) 9592 Ручка FS-051 128 Me золот. матовый (50) 13878 Ручка FS-078 096 St светлый (50) 3832 Ручка FR-006 128 St светлый/St светлый (50) 9595 Ручка FS-046 096 золото (50) 12345 Ручка FB-012 000 St светлый Грибок (100) 13249 Ручка FS-055 128 St светлый (30) 4401 Ручка FS-062 128 Ме золото матовый (50) 9597 Ручка FS-046 128 золото (50) 3161 Ручка FS-086 128 St светлый (50) 18250 Ручка FM-053 032 St светлый (50) 14040 Ручка FS-060 128 Me золот. матовый (50) 10311 Ручка FS-043 160 Cr глянцев/эм.черная 395(18) 13608 Ручка FS-063 096 St светлый (50) 13185 Ручка FS-053 128 St светлый (30) 11528 Ручка FR-006 032 St светлый/St светлый (50) 16427 Ручка FS-046 128 Ni жемчужный (50) 1029 Ручка FS-108 192 Cr матовый (20) 18070 Ручка FM-054 032 St светлый (50) 13250 Ручка FS-055 160 St светлый (20) 13226 Ручка FS-061 128 St светлый (50) 20963 Ручка FS-108 192 St светлый (50) 14320 Ручка FS-081 128 St светлый (50) 8380 Ручка FS-077 160 St светлый (20) 12333 Ручка FM-021 000 St светлый (100) 12555 Ручка FS-076 160 St светлый (20) 2942 Ручка FS-043 160 Cr глянцев/эм.слон.кость 9002(18) 12421 Ручка FM-027 032 St светлый (50) 12689 Ручка FS-049 128 St светлый (20)'; 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