Skip to content

Latest commit

 

History

History
58 lines (42 loc) · 1.74 KB

File metadata and controls

58 lines (42 loc) · 1.74 KB

Pattern Escaping

Pattern escaping distinguishes glob syntax from source text that happens to use the same characters.

How It Works

Patterns use glob control characters, so *, ?, and character classes have special meaning unless they are escaped with a backslash. The anchors ^ and $ are special only at the beginning and end of a pattern part. Use ^^ at the beginning to match a literal caret and $$ at the end to match a literal dollar sign.

The sequence \n separates consecutive pattern lines. Use \\n when the source line contains the literal characters \n.

Literal Asterisk

The pattern Use \* to multiply treats * as source text instead of a wildcard. It matches a line in glob-patterns.txt.

Use * to multiply

Literal Dollar At The End

$ is an end anchor only at the end of a pattern. Use $$ there when the source line itself ends with a dollar sign.

The value ends with $

Literal Caret At The Start

^ is a start anchor only at the start of a pattern. Use ^^ there when the source line itself starts with a caret.

^ starts with caret

Literal Backslash-N Text

Use \\n when the source line contains the characters backslash and n. The quote characters are written as \" so the instruction remains valid XML.

<embed-code file="$java/org/showcase/PatternSamples.java" line="ESCAPED_NEWLINE = "\n"">

private static final String ESCAPED_NEWLINE = "\n";