[英]what regex match strings of characters before ":"
文本示例:
Some string here : my value
Another string : my value
String : my value
我想匹配之前的所有内容,包括符号:
我想要的输出是:
Some string here :
Another string :
String :
谢谢
不要使用正则表达式,因为它不是正则表达式的锤子的钉子。
var strToMatch = "Some string here : my value"; var match = strToMatch.slice(0,strToMatch.indexOf(':')+1); // do something with the match document.body.appendChild(document.createElement('pre')).innerHTML = match;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.