Unterschiede
Hier werden die Unterschiede zwischen der gewählten und der aktuellen Version gezeigt.
en:java:regular-expressions 2012/07/10 18:05 | en:java:regular-expressions 2020/01/22 21:00 aktuell | ||
---|---|---|---|
Zeile 30: | Zeile 30: | ||
* **[abc]** one of the signs in the brackets must appear instead of the bracket-expression ("a[12]b" can match "a1b" and "a2b") | * **[abc]** one of the signs in the brackets must appear instead of the bracket-expression ("a[12]b" can match "a1b" and "a2b") | ||
* **[^abc]** none of the signs in the brackets is allowed to appear instead of the bracket-expressionkeines ("a[^12]b" cannot match "a1b" and "a2b", but "a3b") | * **[^abc]** none of the signs in the brackets is allowed to appear instead of the bracket-expressionkeines ("a[^12]b" cannot match "a1b" and "a2b", but "a3b") | ||
- | * **[a-c]** eines der Zeichen im angegebenen Bereich muss anstelle des Klammer-Ausdrucks vorkommen ("a[1-3]b" passt somit zu "a1b", "a2b" und "a3b", aber nicht zu "a4b") | + | * **[a-c]** one of the signs in the stated area must appear instead of the bracket-expression ("a[1-3]b" matches "a1b", "a2b" and "a3b", but not "a4b") |
- | * **[^a-c]** keines der Zeichen im angegebenen Bereich darf anstelle des Klammer-Ausdrucks vorkommen | + | * **[^a-c]** none of the signs in the stated area is allowed to appear instead of the bracket-expression |
- | * **?** das voranstehende Zeichen darf höchstens einmal vorkommen ("a?b" passt somit zu "ab" und "b", aber nicht zu "aab"). | + | * **?** the precedent sign is allowed to appear once at the most ("a?b" matches "ab" and "b", but not "aab"). |
- | * **\** sorgt vor einem Sonderzeichen dafür, das selbiges als Zeichen interpretiert wird. Zusammen mit bestimmten Buchstaben (\n oder \d) auch für besondere Zeichen. | + | * **\** in front of a special character it makes sure that it is interpreted as a sign. Together with particular letters (\n oder \d) also for special signs. |
- | * **\d** Das Zeichen muss eine Ziffer sein. | + | * **\d** This sign must be a digit. |
- | * **\D** Das Zeichen darf ein beliebiges Zeichen außer einer Ziffer sein. | + | * **\D** This sign is allowed to be any sign except for a digit. |
- | * **\w** Das Zeichen muss aus folgender Menge stammen "0" bis "9", "A" bis "Z", "a" bis "z" und "_". | + | * **\w** This sign must be of the following amount "0" to "9", "A" to "Z", "a" to "z" to "_". |
- | Sollen Sonderzeichen nicht als Steuerzeichen intepretiert werden, sondern als normale Zeichen, so muss ein "\" vorangestellt werden (in Java-String durch ein doppeltes "\\" einzugeben).\\ | + | If you do not want special characters to be interpreted as control characters, but as normal signs, you must add "\" as a prefix (in Java-String you have to input a double "\\").\\ |
\\ | \\ | ||
- | Kleines Java-Beispiel:\\ | + | A little Java-example:\\ |
<code java> | <code java> | ||
- | String str = "hallo.txt"; | + | String str = "hello.txt"; |
- | System.out.println(str.matches("^hallo\\..*")); // true; entspricht einem "hallo.*" | + | System.out.println(str.matches("^hello\\..*")); // true; corresponds to a "hello.*" |
</code> | </code> | ||
\\ | \\ | ||
- | Ausführliche Infos (in engl.) finden sich unter:\\ | + | Detailed information (in engl.) at this page:\\ |
[[http://www.regular-expressions.info]] | [[http://www.regular-expressions.info]] |