I have following div:
<div id = "zone-2fPromotion-2f" class = "promotion">
How can I get value 2f present in the end, actually it is the value of Promotion and how can I retrieve it ?
I was using
this.match = this.id.match(/(Promotion)-([0-9a-f]{2})/);
but it is not giving me exact result but it gives me array of (Promotion-2f, Promotion, 2f) but this is not what I require. Any guidance and also if any one can refer me to good online resource for regex, it would highly helpful and appreciated.
that’s what you want. the results of the match are firstly the entire matched part of the expression, and then the various groups. so since you want to retrieve group 2 (the second lot of ()’s ) just do
also, the best online reference i’ve found is http://www.regular-expressions.info/
edit: you could just leave out the ()’s around Promotion, since you’re not worried about returning that part, and do this