【发布时间】:2014-06-03 05:40:40
【问题描述】:
任何人都可以很好地了解正则表达式,请向我解释为什么这个正则表达式不适用于我的示例文本?或者更好的是,想出一个真正有效的正则表达式。
/((?:(?:ht|f)tps?:\/\/|www)[^<>\]]+?(?![^<>\]]*([>]|<\/))(?=[\s!,\]]|$))/igm
正则表达式来自这个问题:URL replace with anchor, not replacing existing anchors
示例文字:
"This is a simple test. \r\n\r\n" +
"<u><b>A bold header with underscore:<\/b><\/u>\r\n" +
"<i>THESE AREN'T TRANSFORMED. WHY??<\/i>\r\n" +
"* http:\/\/www.example.net\/edit.php\r\n" +
"* http:\/\/www.example.net\/test.php -> Some text\r\n" +
"<i>THESE ARE:<\/i>\r\n" +
"* http:\/\/www.example.net\/invite.php\r\n" +
"* http:\/\/www.example.net\/forums.php\r\n"
【问题讨论】:
标签: javascript regex