Escape of special characters

Source: Internet
Author: User

Escape-related characters include:. * + () $ /\? [] ^ {}, Which must be escaped when searching for these characters separately.

1. jsp --> if a special character (\/.) and other symbols need to be escaped in action, you can use escape (...)

2. characters with special meanings in Java (such as line breaks, carriage returns, single quotes, and double quotation marks). If you want to use it, you must add a prefix "\", such as line feed ("\ n"), carriage return ("\ r"), and double quotation marks ("\"") and backslash.
A. Take the "\" symbol as an example. There are many operations in Java, such as file operations. The path must be used, such as com \ mypackage \ XXX. XML, this path is generally represented in the form of a string, but the problem arises. Java does not know whether your \ number is the meaning of the next layer in the path or the meaning of the string. Therefore, the correct method should be com \ mypackage \ XXX. xml.
B. For example, if we are familiar with \ n and line breaks, if we press enter directly in the middle of the string, Java will not perform line breaks on the string, because he doesn't know if you want to write the code in two lines or split the string into two lines for display, you need to add \ n escape characters in the middle of the string to wrap the string.
C. Take output as an example: the Java say: "Hello world! ". Double quotation marks indicate strings in Java. If they are not escaped, they cannot be output,

Therefore, the escape character system. Out. Print ("the Java say: \" Hello world \ ") is used to output double quotation marks.

Javascript Escape Character
Escape Sequence Character
\ B Return
\ F Take the form of paper
\ N Line feed
\ R Enter
\ T Horizontal hop (CTRL-I)
\' Single quotes
\" Double quotation marks
\\ Backslash

Pay attention to special characters during programming. Many running problems are caused by special characters.

Note: Because the backslash itself is used as an escape character, you cannot directly type A backslash in the script. To generate a backslash, you must enter two backslash (\) together (\\).

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.