I searched around and after running this through a few RegEx builders it seems to do what I want... but when I actually try and implement it it never seems to work.
This is the expression I'm using: (?<=\[)[0-9]+(?:\.[0-9]*)?(?=\])
From my understanding, this is supposed to match any numbers between the [] symbols. I am unconcerned if it is a true float, positive or negative, or any of that, because it is predetermined.
The purpose of this is that I have a set number of prebuilt <select> tags that the website has already built. I need to loop through all of the select tags and get the currently selected option, and inside of that match the number between [].
<select>
<option>Stuff [193.33]</option>
<option>Stuff2 [19232l.39393]</option>
</select>
Something like...
$('#content_area').$('input:select').change(function(){
$('#content_area').$('select option:selected').each(function(){}
I am unaware as to why,
- the expression gives me a syntax error even if I just return it in an alert, and
- how would I construct the loop?
lin<option>Stuff2 [19232l.39393]</option>? I ask because your regex won't match any letters.