方法一: public static int indexOf (字符串/字符,int从第几位开始,int共查几位) string tests = "1absjjkcbfka2rsbcfak2bfka1"; //测试字符串 int i = tests.IndexOf("2b",5,tests.Length-5); //查找从第五字符向后查找“2b” textBox2.Text = i.ToString(); int i = tests.IndexO…
默认情况下,正则表达式 ^ 和 $ 忽略行结束符,仅分别与整个输入序列的开头和结尾匹配.如果激活 MULTILINE 模式,则 ^ 在输入的开头和行结束符之后(输入的结尾)才发生匹配.处于 MULTILINE 模式中时,$ 仅在行结束符之前或输入序列的结尾处匹配. import java.util.regex.Pattern; /** * Created by Frank * 使用正则表达式在文本中查找换行符 */ public class NLMatch { public static voi…
(?<!href="|">)(https?:\/\/[\w\-\.!~?&=+\*\'(),\/]+)((?!\<\/\a\>).)* 这个正则可以匹配文本中以http开头的链接, 但是不会匹配那些已经被A标签包围的链接. 测试文本: Test, Here\'s an interesting in-house litigation position with JPMorgan Chase in New York I thought you might b…
面我们举例一个URL,然后获得它的各个组成部分:http://i.cnblogs.com/EditPosts.aspx?opt=1 1.window.location.href(设置或获取整个 URL 为字符串) var test = window.location.href;alert(test);返回:http://i.cnblogs.com/EditPosts.aspx?opt=1 2.window.location.protocol(设置或获取 URL 的协议部分) var test =…