Created
January 16, 2017 02:04
-
-
Save rj-hwang/64ec67c3720915bffb2ffde72b6048d9 to your computer and use it in GitHub Desktop.
js 正则获取 innerText
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var src = 'AAA <a href="https://baidu.com">abc<b>中国</b>123</a>' | |
var text = src.replace(/<.*?>/ig, '') | |
// or | |
var text = src.replace(/(<([^>]+)>)/ig, '') | |
// result:text="AAA abc中国123" | |
// ref: http://stackoverflow.com/questions/2622903/regex-how-to-get-contents-from-tag-inner-use-javascript |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment