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

    Popular posts from this blog

    Verilog Error: output or inout port "Q" must be connected to a structural net expression -

    jasper reports - How to center align barcode using jasperreports and barcode4j -

    c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -