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
  • 50,146
  • 13
  • 101
  • 111
ngplayground
  • 20,365
  • 36
  • 94
  • 173
  • 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,079
  • 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
  • 30,564
  • 13
  • 72
  • 103
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,666
  • 4
  • 40
  • 55
EZLearner
  • 1,614
  • 16
  • 25