Long story short, I'm trying to "clean up" a script file from a drawing program for playback. The program (ArtRage for iPad) will record all strokes to an XML script file that. You can then export this file and play back the entire drawing process in the iPad or desktop version of the application. I want to clean out all of the "undo" operations.
The drawing "step" looks like this:
<StrokeEvent>
<StrokeHeader>
<EventPt> Wait: 0.428s Loc: (806.416, 439.849) Pr: 1 Ti: 1 Ro: 0 Fw: 1 Bt: 0 Rv: NO Iv: NO </EventPt>
<Recorded> Yes </Recorded>
</StrokeHeader>
Wait: 0.000s Loc: (805.622, 437.537) Pr: 1 Ti: 1 Ro: 0 Fw: 1 Bt: 0 Rv: NO Iv: NO
</StrokeEvent>
I've shortened it up a bit, but the entire thing is contained in opening and closing tags.
The undo operation looks like this:
Wait: 0.661s EvType: Command CommandID: Undo
and it comes right after the step you are undoing.
So ... I'd like to search for just those instances of the complete tag that have an undo operation immediately after it, and then delete both the complete tag and undo line.
I think regex would be a good way to do this, but I don't know it very well. I'm going through a regex class online, but it will just take me a bit to ramp up and this particular solution could come in handy sooner. I've been able to select complete tags, but I can't select just those that have an undo statement following them. I tried using look forward but that selects ALL preceding tags.
Here's the closest I was able to get (excuse the sloppy newbie code):
(<StrokeEvent>[\s\S]+?</StrokeEvent>)\nWait:.*Undo
I thought the "?" after the "+" would enable the lazy option and stop at the first occurrence of , but I may be understanding it wrong.
Anyway, thanks for any tips you can give me!