O'Reilly logo

Reguläre Ausdrücke Kochbuch by Steven Levithan, Jan Goyvaerts

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.4 Optionen für reguläre Ausdrücke setzen

Problem

Sie wollen einen regulären Ausdruck mit allen verfügbaren Modi kompilieren – Freiform-Modus sowie die Modi Groß-/Kleinschreibung ignorieren, Punkt passt zu Zeilenumbruch und Zirkumflex und Dollar passen zu Zeilenumbruch.

Lösung

C#

Regex regexObj = new Regex("Regex-Muster",
    RegexOptions.IgnorePatternWhitespace | RegexOptions.IgnoreCase |
    RegexOptions.Singleline | RegexOptions.Multiline);

VB.NET

Dim RegexObj As New Regex("Regex-Muster",
    RegexOptions.IgnorePatternWhitespace Or RegexOptions.IgnoreCase Or
    RegexOptions.Singleline Or RegexOptions.Multiline)

Java

Pattern regex = Pattern.compile("Regex-Muster", Pattern.COMMENTS | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.DOTALL | Pattern.MULTILINE); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required