0

(1) Website Name

(3) Website Name - 08-08-2013 New York City

From the examples above, how would I be able to remove the rounded brackets and the value inside using jQuery or Javascript?

I understand I would be able to get the title from using the code below

var current_title = $(document).attr('title');

Ian
  • 48,619
  • 13
  • 99
  • 109
ngplayground
  • 18,559
  • 34
  • 93
  • 168
  • possible duplicate of [jQuery remove special characters from string and more](http://stackoverflow.com/questions/8979619/jquery-remove-special-characters-from-string-and-more) – PW Kad Aug 08 '13 at 14:18

3 Answers3

2
var current_title = $(document).attr('title');

current_title = current_title.replace(/^\(\d+\)\s+/,'');

hope this helps

Jake Aitchison
  • 1,039
  • 6
  • 20
2

That's what regular expressions are for. You can try this:

"(3) Website Name - 08-08-2013 New York City".replace(/\(\d+\)/,'')
Teneff
  • 26,872
  • 8
  • 62
  • 92
0

EDIT: Now with more than one digit (or any other characters inside the brackets).

Use:

current_title = current_title.substring(current_title.indexOf(')'));

This should return the rest of the string after the closing bracket.

Check out the function documentation.

Geo
  • 12,222
  • 4
  • 33
  • 54
EZLearner
  • 1,420
  • 14
  • 25