I have an XML document that has end times in there, I need to change the format from this
end="00:00:09:02">
to this
end="00:09.02">
so basically the first two numbers and colon deleted, and the last colon replaced by a period.
I have hundreds to change, and was trying to figure out how to do edit them all using a script of some sort, does anyone have any suggestions?
Here is the original line:
<p start="00:00:13:23" EndTimecode="00:00:17:02" Title='Let’s start with RIM and
the High Velocity Sector.'/>
Here is what I need to end up with:
<p begin="00:13.23" end="00:17.02">Let’s start with RIM and
the High Velocity Sector.</p>
I have updated my question due to discovering that find and replace is the best option.
One way would be regexp.
Regexp:
/(?:EndTimecode="[0-9]{2}):([0-9]{2}):([0-9]{2}):([0-9]{2})(?:")/Replace String:
end="$1:$2.$3"You would use it like so:
$contents)$contents = preg_replace('/(?:EndTimecode="[0-9]{2}):([0-9]{2}):([0-9]{2}):([0-9]{2})(?:")/', 'end="$1:$2.$3"', $contents);$contentsCreate a backup first or write it to a new tmp file!
Edit: See above. The only change was in the regexp.
(?:endwas changed to(?:EndTimecodeEdit2: I hope they all look the same. Try this
Regexp:
/<p start="[0-9]{2}:([0-9]{2}):([0-9]{2}):([0-9]{2})" EndTimecode="[0-9]{2}:([0-9]{2}):([0-9]{2}):([0-9]{2})"\sTitle='(.+?)'/>/Replace String:
<p begin="$1:$2.$3" end="$4:$5.$6">$7</p>