From a0ff7fbcf1f08f7a6f9a8e8daa0fde7954302f71 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Fri, 21 Aug 2009 14:30:17 +0000 Subject: [PATCH] * remove format tags in SubRipReader --- .../sourceforge/filebot/subtitle/SubRipReader.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/source/net/sourceforge/filebot/subtitle/SubRipReader.java b/source/net/sourceforge/filebot/subtitle/SubRipReader.java index 7ff5521e..209f037b 100644 --- a/source/net/sourceforge/filebot/subtitle/SubRipReader.java +++ b/source/net/sourceforge/filebot/subtitle/SubRipReader.java @@ -10,11 +10,13 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.TimeZone; +import java.util.regex.Pattern; public class SubRipReader extends SubtitleReader { private final DateFormat timeFormat; + private final Pattern tag; public SubRipReader(Readable source) { @@ -23,6 +25,9 @@ public class SubRipReader extends SubtitleReader { // format used to parse time stamps (e.g. 00:02:26,407 --> 00:02:31,356) timeFormat = new SimpleDateFormat("HH:mm:ss,SSS", Locale.ROOT); timeFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + + // pattern for , , , and corresponding end tags + tag = Pattern.compile("]*)>", Pattern.CASE_INSENSITIVE); } @@ -50,7 +55,13 @@ public class SubRipReader extends SubtitleReader { lines.add(line); } - return new SubtitleElement(t1, t2, join(lines, "\n")); + return new SubtitleElement(t1, t2, resolve(join(lines, "\n"))); + } + + + protected String resolve(String text) { + // remove tags + return tag.matcher(text).replaceAll(""); } }