Moodkiller Posted December 13, 2014 Report Share Posted December 13, 2014 (edited) Im looking to remove the tags \an* and \pos(*.*,*.*) where * = any number, from a subtitle script. Aegisub has an automation function with a "Strip tags" option...This removes everything within the curly brackets { } for a select line, so I thought it would easy enough to modify this and get it remove the before mentioned tags. Here is the original code (for striping all the tags): local tr = aegisub.gettextscript_name = tr"Strip tags"script_description = tr"Remove all override tags from selected lines"script_author = "Thomas Goyne"script_version = "1"function strip_tags(subs, sel) for _, i in ipairs(sel) do local line = subs[i] line.text = line.text:gsub("{[^}]+}", "") subs[i] = line end aegisub.set_undo_point(tr"strip tags")endaegisub.register_macro(script_name, script_description, strip_tags)Im pretty sure the lineline.text = line.text:gsub("{[^}]+}", "")is the one that needs to be modified. I tried replacing it with this for nowline.text = line.text:gsub("\an5", "")Note: I used 5 as I dont know if wildcards are supported (Im sure they are) and becuase the actual tag I want removed is \an5. Unfortunately this doesn't work. The line stays unmodified after using the script through Aegisub. I haven't attempted removing \pos() yet Solution: To summarize:line.text = line.text:gsub("\\an5", "")line.text = line.text:gsub("\\pos%b()", "")Does exactly what I was looking for. Thanks again JF Source Edited December 13, 2014 by Moodkiller Link to comment Share on other sites More sharing options...
JohnFlower Posted December 13, 2014 Report Share Posted December 13, 2014 (edited) Pretty sure you have to escape your escape character ('\'). Edit: Brackets are evil. Edited December 13, 2014 by JohnFlower 1 Link to comment Share on other sites More sharing options...
Moodkiller Posted December 13, 2014 Author Report Share Posted December 13, 2014 (edited) Pretty sure you have to escape your escape character ('\').Edit: Brackets are evil. Didnt think it would matter seen as it is inside inverted commas? Pre-post edit:Haha holy shit it works!! Just left with the \ now... One step closer Real edit: Spelling Edited December 13, 2014 by Moodkiller Link to comment Share on other sites More sharing options...
JohnFlower Posted December 13, 2014 Report Share Posted December 13, 2014 How? What did you end up using? Link to comment Share on other sites More sharing options...
Moodkiller Posted December 13, 2014 Author Report Share Posted December 13, 2014 Originally this: line.text = line.text:gsub("an5", "") line.text = line.text:gsub("pos", "")which left me with the \ and the pos tag's co-ordinates I.e. \pos(100,100) became \(100.100) And then I changed it to this: line.text = line.text:gsub("an5", "an8") line.text = line.text:gsub("pos", "")As ultimately I wanted the location of the subtitle to be in the top center position/anchored. In the end what I was hoping for this to achieve, isnt so, but thats a different topic altogether. Link to comment Share on other sites More sharing options...
JohnFlower Posted December 13, 2014 Report Share Posted December 13, 2014 line.text = line.text:gsub("\\an5", "")Try that. Link to comment Share on other sites More sharing options...
Moodkiller Posted December 13, 2014 Author Report Share Posted December 13, 2014 Lol, and as simple as that! Thank you. Any ideas to remove the co-ordinates from \pos()? Link to comment Share on other sites More sharing options...
JohnFlower Posted December 13, 2014 Report Share Posted December 13, 2014 (edited) Possibly line.text = line.text:gsub("\\pos%b()", "")Edit: link: http://www.lua.org/pil/20.2.html Edited December 13, 2014 by JohnFlower Link to comment Share on other sites More sharing options...
Moodkiller Posted December 13, 2014 Author Report Share Posted December 13, 2014 That edit... I was just about to post the code that I used, but see you changed it to what I got to work . Thanks for the link, that'll definitely come in handy. To summarize: line.text = line.text:gsub("\\an5", "") line.text = line.text:gsub("\\pos%b()", "")Does exactly what I was looking for. Thanks again JF Link to comment Share on other sites More sharing options...
Baal Posted December 13, 2014 Report Share Posted December 13, 2014 (edited) You know, unanimated has scripts for almost anything you may need http://unanimated.xtreemhost.com/ts/scripts.htm so just learn to use them.I thought I linked his site to you already. You want "Script Cleanup" script. Edited December 13, 2014 by Baal Link to comment Share on other sites More sharing options...
Moodkiller Posted December 14, 2014 Author Report Share Posted December 14, 2014 You know, unanimated has scripts for almost anything you may need http://unanimated.xtreemhost.com/ts/scripts.htm so just learn to use them.I thought I linked his site to you already. You want "Script Cleanup" script. Thanks, I will have a better look through there. I didnt realise he had scripts as well. The page I think you linked to me last time around was the basics of typesetting? I think. The Script Cleanup script: Script Cleanupdelete commentsdelete tagsdelete commented or empty linesclear actor / effect fieldraise dialogue layer by 5clean up tags / remove garbage / round numbersdelete specific tags or groups of related tags (colours, alphas, rotations...)remove linebreaks I assume the "delete tags" will be the one to use. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now