正则表达式用法小结

C#

获得匹配数据

 MatchCollection mc = Regex.Matches(_url, @"href=[""'']([\s\S]*?)[""'']", RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.Singleline);
                                foreach (Match item in mc)
                                    _url = item.Groups[1].Value;

JS

替换

  txt = txt.replace(/(^[\s\n\t]+)|([\s\n\t]+$)/g, '');

 

posted on 2014-04-30 14:18  朝着  阅读(170)  评论(0编辑  收藏  举报