Reputation: 21617
(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');
Upvotes: 0
Views: 122
Reputation: 1834
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.
Upvotes: 0
Reputation: 1099
var current_title = $(document).attr('title');
current_title = current_title.replace(/^\(\d+\)\s+/,'');
hope this helps
Upvotes: 2
Reputation: 32158
That's what regular expressions are for. You can try this:
"(3) Website Name - 08-08-2013 New York City".replace(/\(\d+\)/,'')
Upvotes: 2