View Single Post
Old 01-25-2022, 08:20 PM   #6
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by rdyornot View Post
Thank you - I was afraid of something like this. I'm trying to get the first one or two words from a book or series title - so i'm afraid as far as characters go anything but a space just won't work. If the function won't take a regex or escape character I'll just have to find some other work around.
What you have is almost there. It is putting a space in place of the question mark:

Code:
{series:sublist(0,2, )}
That gets the first two words of the series. And to be clear, there is a space between the comma and the right parenthesis.

But, as @chaley mentioned, there are three modes. I don't like the above version. I would use General Program mode:
Code:
program:
sublist($series, 0, 2, " ")
I can read that and understand it, and there is no reliance on exact formatting of the template.

You could do this with regex:

Code:
program:
re($series, "^(.*? .*?\s).*", "\1")
Or maybe

Code:
program:
re($series, "^(.*?[\s:].*?[\s:]).*", "\1")
If you want to allow any white space or a colon as the separator. Which of the above is suitable depends on what it is you are trying to do.
davidfor is offline   Reply With Quote