I want to get the string which comes between first :
and first .
s:4332Hhj4j32hh432kjh.EF4324rf46543DSVC3443
I tried the following:
/:(.*?)\./g
But still it catches : and .
How can I exclude them?
Here is my example: http://www.regexr.com/3busf
Thanks
Use matches[1]
instead of matches[0]
:
var re = /:(.*?)\\./g; var str = 's:4332Hhj4j32hh432kjh.EF4324rf46543DSVC3443'; var matches; while ((matches = re.exec(str)) !== null) { if (matches.index === re.lastIndex) { re.lastIndex++; } console.log(matches[0]); // ":4332Hhj4j32hh432kjh." console.log(matches[1]); // "4332Hhj4j32hh432kjh" }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.