Quote:
Originally Posted by vargr
Hello, can anyone help with a template I'm trying to make for cover generation? I want it to take a text field that's a series of 2+ names separated by slashes, and return just the first word of each name, retaining the slashes.
i.e., so that "John Doe/Jim Smith" would show as "John/Jim" on the generated cover.
|
One of these should do it. Using general program mode:
Code:
program: list_re(field('#text'), '/', '^(.*)\b.*$', '\1')
Using template program mode:
Code:
{#text:'list_re($, '/', '^(.*)\b.*$', '\1')'}
Change #text to be the lookup name of your text column.
The above also handles single names. For example "John Doe/Fred/Jim Smith" produces "/John/Fred/Jim". If you don't want that then change the \b to a space character.