At first glance, it literally seems like replace replaces only the first occurrence of the character (influenced by JavaScript), ReplaceAll replaces all the characters, in fact, it is not the same as the use of substitution.The two are easy to
Differences between string. Replace () and string. replaceall () in Java and their usage
At first glance, it literally seems that replace only replaces the first character (affected by JavaScript). replaceall replaces all the characters. In
Public static string encodehtml (string s ){
S = S. replaceall ("&","&");
S = S. replaceall ("S = S. replaceall ("","");
S = S. replaceall ("/N", " ");
S = S. replaceall ("/"",""");
S = S. replaceall ("'","'");
Return S;
}
// The Same as
Some time ago, when I was doing a program, I wanted to use the replaceall method. An error was returned. Later I found that this method needed to write a regular expression. Because regular expressions have never been used, they are replaced by
This article describes how to use jsreplace and replaceall instances. For more information, see stringObj. replace (rgExp, replaceText)
Parameters
StringObj
Required. String object or String text to be replaced. The string is not modified by the
Js replace and replaceall instance usage
StringObj. replace (rgExp, replaceText)
Parameters
StringObj
Required. String object or String text to be replaced. The string is not modified by the replace method.
RgExp
Required. It is a regular expression
JS Replace and ReplaceAll instance usage
Stringobj.replace (Rgexp, ReplaceText)
Parameters
Stringobj
Required option. The string object or string literal to perform the substitution. The string is not modified by the Replace method.
Rgexp
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.