In this previous question, I asked how to remove parenteshes and the text inside them. Got this:
$(this).val($(this).val().replace(/\(.+\)/, ''));
So this: food (454) becomes this: food
This works fine but now I would like to not only remove the parentheses and the text between them but also to remove the space before the parentheses.
In the example above, the space I’m talking about would be the space between the letter d and the (
How to modify the code so that it can accomplish that?
No jquery needed at all!
Live demo
Credit to @AnthonyGrist!