Take the 2-minute tour ×

I have a database that contains company information (address, telephone etc)

On some of the telephone numbers it will have an international code: +44 (0) 123 12345

where the (0) will be different numbers depending on country.

I need to strip the (0)

I have the following code:

var el = $('#contactdetails');
el.html(el.html().replace("(0)", "-"));

which works on (0) - but how do I do this for wildcards

share|improve this question

1 Answer 1

Use a regular expression.

var el = $('#contactdetails');
el.html(el.html().replace(/\([0-9]\)/, "-"));

If there is more than a singe digit, then use the * for any number of occurrences of the previous expression.

el.html(el.html().replace(/\([0-9]*\)/, "-"));

Live example here

share|improve this answer
thanks for the prompt reply works great apart from some of the numbers will be 3 characters (758) - i tryed changing [0-9] to [0-999] but no luck - any ideas? –  Jason Jan 5 '11 at 17:10
@Jason - I updated the solution. –  Josiah Ruddell Jan 5 '11 at 17:12
Thanks very much Josiah - Works perfectly –  Jason Jan 5 '11 at 17:24

Your Answer


