匹配某个英文单词的正则表达式如何写
匹配某个英文单词的正则表达式怎么写?
有一堆字符串:HistoryProduct_1,HistoryProduct_2,HistoryProduct_3.......
HistoryProduct帮我匹配这个,我正则表示式的水平太差了,没办法
------解决方案--------------------
String str ="xHistoryProductc";
System.out.print(str.matches(".*HistoryProduct.*"));
------解决方案--------------------
如果是全单词匹配的话,其实直接就是:"HistoryProduct"
------解决方案--------------------
/HistoryProduct_{/d}/
这个是js的,不知道对着java怎么用!
------解决方案--------------------
区分大小写吗?
javascript的
有一堆字符串:HistoryProduct_1,HistoryProduct_2,HistoryProduct_3.......
HistoryProduct帮我匹配这个,我正则表示式的水平太差了,没办法
------解决方案--------------------
String str ="xHistoryProductc";
System.out.print(str.matches(".*HistoryProduct.*"));
------解决方案--------------------
如果是全单词匹配的话,其实直接就是:"HistoryProduct"
------解决方案--------------------
/HistoryProduct_{/d}/
这个是js的,不知道对着java怎么用!
------解决方案--------------------
区分大小写吗?
javascript的
- HTML code
<!doctype html> <html> <head> <meta charset="gb2312" /> <title></title> </head> <body> <script> var data = [ 'HistoryProduct_1', 'HistoryProduct_2', 'HistoryProduct_3', 'xistoryProduct_3', ]; var re = /^HistoryProduct_\d+$/i; for(var i = 0, len = data.length; i < len; i++){ document.write( data[i] + ' ------------ '+ re.test(data[i]) + '<br />' ) } </script> </body> </html>