Difference between revisions of "Java Regular Expressions"
(→Or Verknüpfung) |
(→Or Verknüpfung) |
||
Line 1: | Line 1: | ||
+ | == Metacharacters == | ||
+ | ([{\^-$|]})?*+ <br> | ||
+ | Escaping kann wie folgt gemacht werden: | ||
+ | 1. Backslash oder 2. in \Q \E einbetten | ||
+ | |||
+ | == Character Classes == | ||
+ | *[abc] a, b, or c (simple class) | ||
+ | *[^abc] Any character except a, b, or c (negation) | ||
+ | *[a-zA-Z] a through z, or A through Z, inclusive (range) | ||
+ | *[a-d[m-p]] a through d, or m through p: [a-dm-p] (union) | ||
+ | *[a-z&&[def]] d, e, or f (intersection) | ||
+ | *[a-z&&[^bc]] a through z, except for b and c: [ad-z] (subtraction) | ||
+ | *[a-z&&[^m-p]] a through z, and not m through p: [a-lq-z] (subtraction) | ||
+ | |||
+ | == Predefined Character Classes == | ||
+ | *. Any character (may or may not match line terminators) | ||
+ | *\d A digit: [0-9] | ||
+ | *\D A non-digit: [^0-9] | ||
+ | *\s A whitespace character: [ \t\n\x0B\f\r] | ||
+ | *\S A non-whitespace character: [^\s] | ||
+ | *\w A word character: [a-zA-Z_0-9] | ||
+ | *\W A non-word character: [^\w] | ||
+ | |||
== Or Verknüpfung == | == Or Verknüpfung == | ||
Or Verknüpfungen werden mit einem vertikalen Strich gemacht. Beispiel: | Or Verknüpfungen werden mit einem vertikalen Strich gemacht. Beispiel: | ||
"text1|text2|text3" | "text1|text2|text3" |
Revision as of 16:01, 13 June 2008
Metacharacters
([{\^-$|]})?*+
Escaping kann wie folgt gemacht werden:
1. Backslash oder 2. in \Q \E einbetten
Character Classes
- [abc] a, b, or c (simple class)
- [^abc] Any character except a, b, or c (negation)
- [a-zA-Z] a through z, or A through Z, inclusive (range)
- [a-d[m-p]] a through d, or m through p: [a-dm-p] (union)
- [a-z&&[def]] d, e, or f (intersection)
- [a-z&&[^bc]] a through z, except for b and c: [ad-z] (subtraction)
- [a-z&&[^m-p]] a through z, and not m through p: [a-lq-z] (subtraction)
Predefined Character Classes
- . Any character (may or may not match line terminators)
- \d A digit: [0-9]
- \D A non-digit: [^0-9]
- \s A whitespace character: [ \t\n\x0B\f\r]
- \S A non-whitespace character: [^\s]
- \w A word character: [a-zA-Z_0-9]
- \W A non-word character: [^\w]
Or Verknüpfung
Or Verknüpfungen werden mit einem vertikalen Strich gemacht. Beispiel: "text1|text2|text3"