mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-23 00:08:51 -05:00
Add String.initialName() for "James Cameron" ➔ "J. Cameron"
This commit is contained in:
parent
f8e3c3460d
commit
8c8e1045fb
@ -8,6 +8,7 @@ import static net.filebot.WebServices.*;
|
|||||||
import static net.filebot.format.ExpressionFormatFunctions.*;
|
import static net.filebot.format.ExpressionFormatFunctions.*;
|
||||||
import static net.filebot.media.MediaDetection.*;
|
import static net.filebot.media.MediaDetection.*;
|
||||||
import static net.filebot.util.RegularExpressions.*;
|
import static net.filebot.util.RegularExpressions.*;
|
||||||
|
import static net.filebot.util.StringUtilities.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -227,6 +228,14 @@ public class ExpressionFormatMethods {
|
|||||||
return compile("^(The|A|An)\\s(.+)", CASE_INSENSITIVE | UNICODE_CHARACTER_CLASS).matcher(self).replaceFirst(replacement).trim();
|
return compile("^(The|A|An)\\s(.+)", CASE_INSENSITIVE | UNICODE_CHARACTER_CLASS).matcher(self).replaceFirst(replacement).trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String initialName(String self) {
|
||||||
|
String[] words = SPACE.split(self);
|
||||||
|
for (int i = 0; i < words.length - 1; i++) {
|
||||||
|
words[i] = words[i].charAt(0) + ".";
|
||||||
|
}
|
||||||
|
return join(words, " ");
|
||||||
|
}
|
||||||
|
|
||||||
public static String sortInitial(String self) {
|
public static String sortInitial(String self) {
|
||||||
// use primary initial, ignore The XY, A XY, etc
|
// use primary initial, ignore The XY, A XY, etc
|
||||||
char c = ascii(sortName(self)).charAt(0);
|
char c = ascii(sortName(self)).charAt(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user