If there is a string like this " www.com.baidu.com "
What I want to match is all the strings after the first com, but excluding " com ", how should I write the regular expression? ? That is to say, the desired string is ".baidu.com"
It is best not to match it by capturing groups;
漂亮男人2017-05-19 10:12:44
var str = 'www.com.baidu.com'
var result = /.*?com(.*)/.exec(str)
console.log(result[1])
高洛峰2017-05-19 10:12:44
We are both newbies and have the same question.
I guess before the text is taken out, set an intermediate state to accept the string width of the text, subtract the first 3, and then assign it to the calling one.
(The above are all my guesses.)
曾经蜡笔没有小新2017-05-19 10:12:44
'www.com.baidu.com'.match(/.+\.com(.+)/)[1]
// ".baidu.com"
The regular diagram above:,