String litertal consist zero or more character enclosed by double quote("). Use escape sequences(listed below) to represent special characters within a string. It is a compile-time error for a newline or EOF characterto appear inside a string literal. All the supported escape sequences are as follow:
\\t tab
\\" double quote
\\ backslash
The following are valid examples of string literal:
Can you help me write a regex match string literal? Thanks so much.
The most general way is to use Pattern.quote()
method which returns a regular expression that matches the literal string passed as its argument. You can use it in Scala as well as in Java.
如果要匹配例如由文字"contain tab \\t"
表示的字符串,则可以使用正则表达式"contain tab \\t".r
.r-因此,在正则表达式中不需要对TAB进行任何特殊处理。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.