为什么要对字符串编码? 某些字符串中包含html标签,不编码,页面输出就乱了. PHP下怎么对字符串编码? htmlentities vs htmlspecialchars htmlentities 与htmlspecialchar 区别: htmlentities is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character…
近日在做项目的时候,经常会在页面上处理一些数据.结果发现自己js掌握的并不是很好.那就在这里记录js的点点滴滴吧. 1. 去除字符串中的 html 标签 function delHtmlTag(str){ return str.replace(/<[^>]+>/g,""); } var str = "<span style='display:none;'>This is test</span><br/>"; st…
Given an input string, reverse the string word by word. A word is defined as a sequence of non-space characters.The input string does not contain leading or trailing spaces and the words are always separated by a single space.For example,Given s = "t…
public class Solution { public String replaceSpace(StringBuffer str) { String str1=str.toString(); char[] charArray = str1.toCharArray(); StringBuilder sBuilder = new StringBuilder(); for (char c : charArray) { if(c==' ') { sBuilder.append("%20"…