RegExp Pada PHP Dan Perl
Pattern | Penjelasan | ||
[abc] | A single character: a, b or c | ||
[^abc] | Any single character but a, b, or c | ||
[a-z] | Any single character in the range a-z | ||
[a-zA-Z] | Any single character in the range a-z or A-Z | ||
^ | Start of line | ||
$ | End of line | ||
\A | Start of string | ||
\z | End of string | ||
. | Any single character | ||
\s | Any whitespace character | ||
\S | Any non-whitespace character | ||
\d | Any digit | ||
\D | Any non-digit | ||
\w | Any word character (letter, number, underscore) | ||
\W | Any non-word character | ||
\b | Any word boundary character | ||
(...) | Capture everything enclosed | ||
(a|b) | a or b | ||
a? | Zero or one of a | ||
a* | Zero or more of a | ||
a+ | One or more of a | ||
a{3} | Exactly 3 of a | ||
a{3,} | 3 or more of a | ||
a{3,6} | Between 3 and 6 of a |
i = Case Sensitive
m = Make dot match newlines
x = Ignore whitespace in regex
o = Perform #{....} substitutions only once
Regular Expression | Will match... |
foo | The string "foo" |
^foo | "foo" at the start of a string |
foo$ | "foo" at the end of a string |
^foo$ | "foo" when it is alone on a string |
[abc] | a, b, or c |
[a-z] | Any lowercase letter |
[^A-Z] | Any character that is not a uppercase letter |
(gif|jpg) | Matches either "gif" or "jpeg" |
[a-z]+ | One or more lowercase letters |
[0-9\.\-] | Аny number, dot, or minus sign |
^[a-zA-Z0-9_]{1,}$ | Any word of at least one letter, number or _ |
([wx])([yz]) | wy, wz, xy, or xz |
[^A-Za-z0-9] | Any symbol (not a number or a letter) |
([A-Z]{3}|[0-9]{4}) | Matches three letters or four numbers |
Sekedar dokumentasi aja nanti saya jabarkan satu-satu pada seri RegExp berikutnya
Pattern | Penjelasan | ||
[abc] | A single character: a, b or c | ||
[^abc] | Any single character but a, b, or c | ||
[a-z] | Any single character in the range a-z | ||
[a-zA-Z] | Any single character in the range a-z or A-Z | ||
^ | Start of line | ||
$ | End of line | ||
\A | Start of string | ||
\z | End of string | ||
. | Any single character | ||
\s | Any whitespace character | ||
\S | Any non-whitespace character | ||
\d | Any digit | ||
\D | Any non-digit | ||
\w | Any word character (letter, number, underscore) | ||
\W | Any non-word character | ||
\b | Any word boundary character | ||
(...) | Capture everything enclosed | ||
(a|b) | a or b | ||
a? | Zero or one of a | ||
a* | Zero or more of a | ||
a+ | One or more of a | ||
a{3} | Exactly 3 of a | ||
a{3,} | 3 or more of a | ||
a{3,6} | Between 3 and 6 of a |
0 komentar:
Posting Komentar