I have the following text:
<clipPath id="p54dfe3d8fa">
<path d="M 112.176 307.8
L 112.176 307.8
L 174.672 270
L 241.632 171.72
L 304.128 58.32
L 380.016 171.72
L 442.512 217.08
L 491.616 141.48
L 491.616 307.8
z
"/>
</clipPath>
<clipPath id="p27c84a8b3c">
<rect height="302.4" width="446.4" x="72.0" y="43.2"/>
</clipPath>
I need to grab this portion out:
d="M 112.176 307.8
L 112.176 307.8
L 174.672 270
L 241.632 171.72
L 304.128 58.32
L 380.016 171.72
L 442.512 217.08
L 491.616 141.48
L 491.616 307.8
z
"
I need to replace this section with something else. I was able to grab the entirety of <clipPath ...><path d="[code i want]"/>
but this doesn't help me because I can't override the id in the <clipPath>
element.
Note that there are other <clipPath>
elements that I do not want to touch. I only want to change <path>
elements within <clipPath>
elements.
I'm thinking that the answer has to do with selecting everything before a clipPath element and ending at the Path section. Any help would be entirely appreciated.
I've been using http://pythex.org/ for help and have also seen odd behavior (having to do with multiline and spaces) that don't act the same between that and python 3.x code.
Here are some of the things I've tried:
reg = r'(<clipPath.* id=".*".*>)'
reg = re.compile(r'(<clipPath.* id=".*".*>\s*<path.*d="(.*\n)+")')
reg = re.compile(r'((?<!<clipPath).* id=".*".*>\s*<path.*d="(.*\n)+")')
g = reg.search(text)
g