I have a string that and I am trying to extract the characters before the quote.
Example is extract the 14 from 14′ – €14.99
I am using the follwing code to acheive this.
$menuItem.text().match(/[^']*/)[0]
My problem is that if the string is something like €0.88 I wish to get an empty string returned. However I get back the full string of €0.88.
What I am I doing wrong with the match?
This is the what you should use to split:
And then to handle your non existant value edge case:
Demo on JsFiddle