Java escape characters

Source: Internet
Author: User

/N press enter (/u000a) <br/>/T horizontal tab (/u0009) <br/>/B space (/u0008) <br/>/R line feed (/u000d) <br/>/F form feed (/u000c) <br/>/'single quotation marks (/u0027) <br/>/"Double quotation marks (/u0022) <br/> // backslash (/u005c) <br/>/DDD three-digit octal <br/>/udddd 4-digit hexadecimal <br/>

 

 

Other characters to be escaped, such

 

String sname = "Java escape character (Addendum)"; <br/> sname = sname. replacefirst ("(Addendum)", ""); <br/> out. println (sname); <br/>

 

 

If you think it will output "Java escape characters", you will be wrong. In fact, the output of "Java escape characters ()" is also very strange. I thought it was a question of Chinese and English parentheses, but no. I'm not sure whether to escape the problem. The solution is

Sname = sname. replacefirst ("// (Addendum //)", ""); </P> <p> sname = sname. replacefirst ("(Addendum)", ""); <br/>

 

 

"(Addendum)" is considered a regular expression, rather than a normal string (). In a regular expression, it is used to mark a substring. $1 can be used, $2 and so on to obtain the matching string "// (Addendum //)" first, the string actually represented in Java "/(addendum /) "Then the string is a/Escape Character in the regular expression.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.