I'm looking to strip out some contents from the page <title>
on click with JavaScript.
Before: (1) Hello World
(value in brackets can change)
After: Hello World
What would be the best document.title.replace()
regex to capture this (1)
part (with a space after it)?
document.title.replace(/\(\d+\)\s/, '')
So this matches a string starting with a (
, then one or more of a digit, then )
and finally a space. This will match (1)
or even (556)
.
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.