javascript - Extract svg path with regex -
i want extract svg path using regex , javascript, doesn't work.
my svg file :
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100" height="100" viewbox="0 0 100 100"> <path d="m0.675,11.333h98.849v21.182h0.675v11.333z m0.675,39.576h98.849v21.183h0.675v39.576z m0.675,67.818h98.849v21.184h0.675 v67.818z"/> </svg>
my regex : /^<path(.*)\/>$/gm
i'd : <path d="m0.675,11.333h98.849v21.182h0.675v11.333z m0.675,39.576h98.849v21.183h0.675v39.576z m0.675,67.818h98.849v21.184h0.675 v67.818z"/>
and no results...
dot in js regex won't match line breaks.
var s = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100" height="100" viewbox="0 0 100 100">\n<path d="m0.675,11.333h98.849v21.182h0.675v11.333z m0.675,39.576h98.849v21.183h0.675v39.576z m0.675,67.818h98.849v21.184h0.675\nv67.818z"/>\n</svg>'; alert(s.match(/<path\b([\s\s]*?)\/>/g))
[\s\s]*
matches character including line breaks.
Comments
Post a Comment