Table 4-1. Regular expression operators
| Operator | Effect |
|---|---|
| . | Matches any single character. |
| ? | The preceding item is optional and will be matched, at most, once. |
| * | The preceding item will be matched zero or more times. |
| + | The preceding item will be matched one or more times. |
| {N} | The preceding item is matched exactly N times. |
| {N,} | The preceding item is matched N or more times. |
| {N,M} | The preceding item is matched at least N times, but not more than M times. |
| – | represents the range if it’s not first or last in a list or the ending point of a range in a list. |
| ^ | Matches the empty string at the beginning of a line; also represents the characters not in the range of a list. |
| $ | Matches the empty string at the end of a line. |
| \b | Matches the empty string at the edge of a word. |
| \B | Matches the empty string provided it’s not at the edge of a word. |
| \< | Match the empty string at the beginning of word. |
| \> | Match the empty string at the end of word. |
| Besondere Zeichen | |
|---|---|
| z | Ein beliebiges Zeichen z |
| \\ | Der Gegenschräger (Backslash) |
| \0nnn | Zeichen mit oktaldezimalem Wert 0nnn |
| \xnnn | Zeichen mit hexadezimalem Wert 0nnn |
| \t | Tabulator |
| \n | Zeilenumbruch (Newline) |
| \r | Wagenrücklauf (Carriage Return) |
| \f | Zeichenvorschub (Form Feed) |
| \a | Piepton (Beep) |
| \e | Escape |
| \cz | Kontrollzeichen korrespondierend zu z |
| Vordefinierte Zeichenklassen | |
| . | Jedes Zeichen (Einstellbar ob auch Umbrüche enthalten sind) |
| \d | Beliebiges Ziffernzeichen; identisch mit [0-9] |
| \D | Alle Zeichen außer Ziffern; identisch mit [^0-9] |
| \s | Leerraumzeichen (White Space); identisch mit [ \t\n\x0B\f\r] |
| \S | Alle Zeichen außer Leerraum; identisch mit [^\s] |
| \w | Jedes alphanummerisches Zeichen; identisch mit [a-zA-Z_0-9] |
| \W | Alle Zeichen außer Jedes alphanummerische; identisch mit [^\w] |
| Eigene Zeichenklassen | |
| [abc] | a, b oder c, (Einfache Klasse) |
| [^abc] | Alles außer a, b oder c (Negierung) |
| [a-z] | a bis z oder A bis Z (einfacher Zeichenbereich) |
| [a-m[n-p]] | a bis m oder n bis p; identisch mit [a-dm-p] (Vereinigung) |
| [a-z&&[egf]] | e, g oder f (Untermenge) |
| [a-z&&[^bc]] | a bis z, ohne b und ohne c (Zeichenbereich mit Auschluss) |
| Grenzbezüge | |
| ^ | Start einer Zeile oder Beginn des Textes |
| $ | Zeilenende oder Ende des Textes |
| \b | Wortgrenze |
| \B | Alles außer eine Wortgrenze |
| \A | Beginn des Textes |
| \G | The end of the previous match |
| \Z | Ende des Textes oder des Textabschlusses |
| \z | Ende des Textes |
| Quantitäten | |
| X? | X genau einmal oder überhaupt nicht |
| X* | X 0 Mal bis viele |
| X+ | X 1 Mal bis viele |
| X{n} | X genau n Mal |
| X{n,} | X mindestens n Mal bis viele |
| X{n,m} | X n bis m Mal |
| Quantitäten (nicht gefräßig, so wenig wie möglich) | |
| X*? | X 0 Mal bis so wenig wie möglich |
| X+? | X 1 mal bis so wenig wie möglich |
| X{n,}? | X mindestens n Mal bis so wenig wie möglich |
| X{n,m}? | X mindestens n Mal bis höchsten m Mal |
| Quantitäten (gefräßig, so viel wie möglich) | |
| X*+ | X 0 Mal bis so viel wie möglich |
| X++ | X 1 Mal bis so viel wie möglich |
| X{n,}+ | X mindestens n Mal bis so viel wie möglich |
| X{n,m}+ | X mindestens n und maximal m Mal |
| Aneinanderreihung und Gruppierung | |
| XY | X gefolgt von Y |
| X|Y | Entweder X oder Y |
| (X) | X als Gruppe mit späterer Bezugsmöglichkeit $n |
| (?:X) | X als Gruppe ohne späterer Bezugsmöglichkeit |
credits: http://www.regexe.de/hilfe.jsp
liked this article?
- only together we can create a truly free world
- plz support dwaves to keep it up & running!
- (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
- really really hate advertisement
- contribute: whenever a solution was found, blog about it for others to find!
- talk about, recommend & link to this blog and articles
- thanks to all who contribute!