From 86d448a5d8008919684737341f08cd94e371517c Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sun, 20 Oct 2013 04:21:22 +0000 Subject: [PATCH] * short-hand for "Put the The|A|An at the end --- .../net/sourceforge/filebot/format/ExpressionFormat.lib.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/net/sourceforge/filebot/format/ExpressionFormat.lib.groovy b/source/net/sourceforge/filebot/format/ExpressionFormat.lib.groovy index 11310866..ccd96aa6 100644 --- a/source/net/sourceforge/filebot/format/ExpressionFormat.lib.groovy +++ b/source/net/sourceforge/filebot/format/ExpressionFormat.lib.groovy @@ -97,7 +97,8 @@ String.metaClass.upperInitial = { replaceAll(/(?<=[&()+.,-;<=>?\[\]_{|}~ ]|^)[a- * * e.g. "Deep Space 9" -> "DS9" */ -String.metaClass.acronym = { delegate.after(/^(?i)(The|A|An)\s/).trim().findAll(/(?<=[&()+.,-;<=>?\[\]_{|}~ ]|^)[\p{Alnum}]/).join().toUpperCase() } +String.metaClass.acronym = { delegate.sortName('$2').findAll(/(?<=[&()+.,-;<=>?\[\]_{|}~ ]|^)[\p{Alnum}]/).join().toUpperCase() } +String.metaClass.sortName = { replacement = '$2, $1' -> delegate.replaceFirst(/^(?i)(The|A|An)\s(.+)/, replacement).trim() } /** * Lower-case all letters that are not initials.