javascript - How do I extract specific text with regex -
Here is the code that I used to remove 2 groups, i.e. percentages and colors to apply regex to the input group Was there.
var variable = "#clasemedia [percent \ ltd; = 100] {polygon-fill: # b 20026;} # clasamedia [percent ; Percent" + Promotion + "Color" + Color + "& lt; / li & gt;"); } The output of the above code is as follows: percent [percent desired output: percent 100 colors # b 20026 JS Fiddle - < / Div>
promedio = pollo [i] .mail (/ \ [\ s + (\ w + \ s + \ & Lt; \ = \ S + \ d [0- 9] +) \] \ s / g). Pop () Match (/ (\ d +) / g). Pop () color = pollo [i] .match (/ \ {[\ s + \ w \ w \:. \ S + # \ w \ s +;] \} / g) .pop () match (/ # [One-zA-Z0-9] * / g) .pop () Here you go, Regex needs to be corrected, currently gives you an array, so You see distorted out
Percent 100 colors # b 20026
Percent 74color # dead 181d Better reggae < ul>
for promedio - (/ percent \ s * \ & lt; \ = \ s * (\ d *) / g) .exec (pollo [i]). Pop () For Color - pollo [i] .match (/ # [a-zA-Z0-9] * /g).pop () or composite
`
var x = (/ percent \ s * \ & lt; \ = \ s * (\ d * ) * \ * # ([One-zA-Z0-9] *) / g) .exec (polo [i]) .. // output ["percent \" = 100] {polygon-full: # b 20026 "," 100 "," b 20026 "] color = x.pop (); promedio = x.pop (); `
Comments
Post a Comment