[英]jQuery replace brackets in title
I'm looking to strip out some contents from the page <title>
on click with JavaScript. 我希望从JavaScript单击时从<title>
页中删除一些内容。
Before: (1) Hello World
(value in brackets can change) 之前: (1) Hello World
(括号中的值可以更改)
After: Hello World
之后: Hello World
What would be the best document.title.replace()
regex to capture this (1)
part (with a space after it)? 捕获这(1)
部分(后接空格document.title.replace()
的最佳document.title.replace()
正则表达式是什么?
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)
. 这将匹配(1)
甚至(556)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.