Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using regular expressions with xml files 1

Status
Not open for further replies.

starlightZZ

Programmer
Mar 13, 2008
2
FR
Hi
I have a huge batch of subtitle xml files that have been coded with the wrong timings.

Is there a way of writing a regular expression to add (for example) 7 seconds to each caption time...

FOR THE FOLLOWING CAPTIONS I WANT TIME= 7, 10, 13 - without having to handcode these files

<CAPTION TIME="0" TEXT="The green cards are ok"></CAPTION>
<CAPTION TIME="3" TEXT="the pink cards are better"></CAPTION>
<CAPTION TIME="6" TEXT="you'll see that underneath the cards that i chose"></CAPTION>


----

i think in macromedia dreamweaver there should be a regular expression that is well capable of helping me..
something like:
search and replace
caption time="[$$]"
with
caption time="[$$+7]"

can anyone help???
if not i have about 100 hours of coding to get on with

Thanks lots guys


 
I have got a little further

the SEARCH field is:
<CAPTION TIME="*[0-9]"

the REPLACE field seems to be just writing the exact code that i try though....(not calculating and repacing)
I have tried replacing with:

<CAPTION TIME="$Var%1>05>$"

<CAPTION TIME="[%1>05>]"

<CAPTION TIME="*[?>05>]"

All help gratefully received
S
 
>I have a huge batch of subtitle xml files...
In that case, personally, I would run a script on the server to do some administration/maintenance job to successively load (into xml dom object), edit (SelectNodes("//CAPTION/@TIME") and add numerically 7 to them), and save (.Save) and persist the change to replace the files. What kind of script? would depend on the environment and your specialized skills. For server-side cf, you can check out, maybe dated, articles such as:

I would be less likely using regexp to edit the files as plain text file, though nothing wrong with the approach.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top