diff --git a/source/net/filebot/format/ExpressionFormat.java b/source/net/filebot/format/ExpressionFormat.java index 1c0a70d5..1b7da84a 100644 --- a/source/net/filebot/format/ExpressionFormat.java +++ b/source/net/filebot/format/ExpressionFormat.java @@ -1,5 +1,6 @@ package net.filebot.format; +import static net.filebot.similarity.Normalization.*; import static net.filebot.util.ExceptionUtilities.*; import static net.filebot.util.FileUtilities.*; import groovy.lang.GroovyClassLoader; @@ -198,7 +199,7 @@ public class ExpressionFormat extends Format { protected Object normalizeBindingValue(Object value) { // if the binding value is a String, remove illegal characters if (value instanceof CharSequence) { - return replacePathSeparators(value.toString()).trim(); + return replaceSpace(replacePathSeparators((CharSequence) value), " ").trim(); } // if the binding value is an Object, just leave it diff --git a/source/net/filebot/similarity/Normalization.java b/source/net/filebot/similarity/Normalization.java index 42a1afd5..06e8812a 100644 --- a/source/net/filebot/similarity/Normalization.java +++ b/source/net/filebot/similarity/Normalization.java @@ -9,6 +9,9 @@ public class Normalization { private static final Pattern apostrophe = compile("['`´‘’ʻ]+"); private static final Pattern punctuation = compile("[\\p{Punct}\\p{Space}]+"); + private static final Pattern space = compile("\\s+"); + private static final Pattern spaceLikePunctuation = compile("[:?._]"); + private static final Pattern[] brackets = new Pattern[] { compile("\\([^\\(]*\\)"), compile("\\[[^\\[]*\\]"), compile("\\{[^\\{]*\\}") }; private static final Pattern trailingParentheses = compile("(?