![]() For example:Įnter input string to search: found the text starting at index 0 and ending at index 1. If you are using an escaped construct within a string literal, you must precede the backslash with another backslash for the string to compile. String Literals section where we mentioned the use of backslash and \Q and \E for quotation. They make your code easier to read and eliminate errors introduced by malformed character classes.Ĭonstructs beginning with a backslash are called escaped constructs. Use the predefined classes whenever possible. For example, \d means a range of digits (0-9), and \w means a word character (any lowercase letter, any uppercase letter, the underscore character, or any digit). In the table above, each construct in the left-hand column is shorthand for the character class in the right-hand column. Pattern API contains a number of useful predefined character classes, which offer convenient shorthands for commonly used regular expressions:Īny character (may or may not match line terminators)
0 Comments
Leave a Reply. |