Skip html labels in JS

2020-07-27
basic
1
str = str.replace(/<[^<>]+>/g, '');

sample:

1
2
3
4
var error = "<html><head><title>Error</title></head><body>Unauthorized</body></html>";
error = error.replace(/<[^<>]+>/g, '');
console.log(error);
// print ErrorUnauthorized
Share
  • js
Newer posts
Sonar Fix (Java backend)
Olde posts
NPM tips
  • visitors
  • © 2022 B. Orianna Shi
  • Powered by Hexo
  • Theme Ocean
Solito
  • Home
  • Archives
  • Gallery
  • About
  • Search