Wzorzec Regex
JSPCRE
//
Wynik dopasowania
Brak dopasowańKlasy znaków
| Składnia | Znaczenie | JS | PCRE | Python | Java |
|---|---|---|---|---|---|
| \d | Digit [0-9] | ✅ | ✅ | ✅ | ✅ |
| \D | Non-digit [^0-9] | ✅ | ✅ | ✅ | ✅ |
| \w | Word character [a-zA-Z0-9_] | ✅ | ✅ | ✅ | ✅ |
| \W | Non-word character | ✅ | ✅ | ✅ | ✅ |
| \s | Whitespace | ✅ | ✅ | ✅ | ✅ |
| \S | Non-whitespace | ✅ | ✅ | ✅ | ✅ |
| . | Any character (except newline) | ✅ | ✅ | ✅ | ✅ |
| [abc] | Character class (match a/b/c) | ✅ | ✅ | ✅ | ✅ |
| [^abc] | Negated class (not a/b/c) | ✅ | ✅ | ✅ | ✅ |
| [[:alpha:]] | POSIX alpha class | ❌ | ✅ | ✅ | ❌ |
| [[:digit:]] | POSIX digit class | ❌ | ✅ | ✅ | ❌ |
| \p{L} | Unicode letter | ✅ | ✅ | ⚠️ | ✅ |
| \p{N} | Unicode number | ✅ | ✅ | ⚠️ | ✅ |
| \X | Unicode extended grapheme cluster | ❌ | ✅ | ❌ | ❌ |
Kwantyfikatory
| Składnia | Znaczenie | JS | PCRE | Python | Java |
|---|---|---|---|---|---|
| * | Zero or more | ✅ | ✅ | ✅ | ✅ |
| + | One or more | ✅ | ✅ | ✅ | ✅ |
| ? | Zero or one | ✅ | ✅ | ✅ | ✅ |
| {n} | Exactly n times | ✅ | ✅ | ✅ | ✅ |
| {n,m} | Between n and m times | ✅ | ✅ | ✅ | ✅ |
| *? | Zero or more (lazy) | ✅ | ✅ | ✅ | ✅ |
| +? | One or more (lazy) | ✅ | ✅ | ✅ | ✅ |
| ?? | Zero or one (lazy) | ✅ | ✅ | ✅ | ✅ |
| {n,m}? | Between n and m (lazy) | ✅ | ✅ | ✅ | ✅ |
| *+ | Zero or more (possessive) | ❌ | ✅ | ❌ | ✅ |
| ++ | One or more (possessive) | ❌ | ✅ | ❌ | ✅ |
| ?+ | Zero or one (possessive) | ❌ | ✅ | ❌ | ✅ |
Kotwice
| Składnia | Znaczenie | JS | PCRE | Python | Java |
|---|---|---|---|---|---|
| ^ | Start of string (line start in multiline) | ✅ | ✅ | ✅ | ✅ |
| $ | End of string (line end in multiline) | ✅ | ✅ | ✅ | ✅ |
| \b | Word boundary | ✅ | ✅ | ✅ | ✅ |
| \B | Non-word boundary | ✅ | ✅ | ✅ | ✅ |
| \A | Absolute start of string | ❌ | ✅ | ✅ | ✅ |
| \Z | Absolute end (before newline) | ❌ | ✅ | ✅ | ✅ |
| \z | Very end (after newline) | ❌ | ✅ | ✅ | ❌ |
| \G | End of previous match | ❌ | ✅ | ✅ | ✅ |
Grupy i referencje
| Składnia | Znaczenie | JS | PCRE | Python | Java |
|---|---|---|---|---|---|
| (...) | Capturing group | ✅ | ✅ | ✅ | ✅ |
| (?:...) | Non-capturing group | ✅ | ✅ | ✅ | ✅ |
| (?<name>...) | Named group (JS/Java style) | ✅ | ⚠️ | ✅ | ✅ |
| (?P<name>...) | Named group (Python style) | ❌ | ✅ | ✅ | ❌ |
| \1 | Backreference to group N | ✅ | ✅ | ✅ | ✅ |
| $1 | Replacement ref to group N | ✅ | ❌ | ❌ | ✅ |
| \k<name> | Named backreference | ✅ | ✅ | ✅ | ✅ |
| (?|...) | Branch reset group | ❌ | ✅ | ❌ | ❌ |
| (?>...) | Atomic group (no backtracking) | ❌ | ✅ | ❌ | ✅ |
Lookaround
| Składnia | Znaczenie | JS | PCRE | Python | Java |
|---|---|---|---|---|---|
| (?=...) | Positive lookahead | ✅ | ✅ | ✅ | ✅ |
| (?!...) | Negative lookahead | ✅ | ✅ | ✅ | ✅ |
| (?<=...) | Positive lookbehind | ✅ | ✅ | ✅ | ✅ |
| (?<!...) | Negative lookbehind | ✅ | ✅ | ✅ | ✅ |
Modyfikatory
| Składnia | Znaczenie | JS | PCRE | Python | Java |
|---|---|---|---|---|---|
| (?i) | Case insensitive | ✅ | ✅ | ✅ | ✅ |
| (?-i) | Case sensitive | ❌ | ✅ | ❌ | ⚠️ |
| (?m) | Multiline (^/$ match line starts/ends) | ✅ | ✅ | ✅ | ✅ |
| (?s) | Dotall (. matches newline) | ✅ | ✅ | ⚠️ | ✅ |
| (?x) | Extended (ignore whitespace & # comments) | ❌ | ✅ | ✅ | ✅ |
| (?i:...) | Inline case insensitive | ✅ | ✅ | ❌ | ✅ |
PCRE zaawansowany
| Składnia | Znaczenie | JS | PCRE | Python | Java |
|---|---|---|---|---|---|
| \K | Reset match start | ❌ | ✅ | ❌ | ❌ |
| (*SKIP) | Skip current match | ❌ | ✅ | ❌ | ❌ |
| (*FAIL) | Force match failure | ❌ | ✅ | ❌ | ❌ |
| (?(cond)yes|no) | Conditional expression | ❌ | ✅ | ❌ | ❌ |
| (?R) | Recurse entire pattern | ❌ | ✅ | ❌ | ❌ |
| (?1) | Subroutine call to group 1 | ❌ | ✅ | ❌ | ❌ |