mirror of
https://github.com/fergalmoran/picard.git
synced 2026-02-27 10:03:59 +00:00
PICARD-923: Add startswith and endswith script functions
This commit is contained in:
@@ -684,6 +684,18 @@ def func_firstwords(parser, text, length):
|
||||
return text[:length].rsplit(' ', 1)[0]
|
||||
|
||||
|
||||
def func_startswith(parser, text, pattern):
|
||||
if text.startswith(pattern):
|
||||
return "1"
|
||||
return "0"
|
||||
|
||||
|
||||
def func_endswith(parser, text, pattern):
|
||||
if text.endswith(pattern):
|
||||
return "1"
|
||||
return "0"
|
||||
|
||||
|
||||
def func_truncate(parser, text, length):
|
||||
try:
|
||||
length = int(length)
|
||||
@@ -817,6 +829,8 @@ register_script_function(func_is_complete, "is_complete")
|
||||
register_script_function(func_firstalphachar, "firstalphachar")
|
||||
register_script_function(func_initials, "initials")
|
||||
register_script_function(func_firstwords, "firstwords")
|
||||
register_script_function(func_startswith, "startswith")
|
||||
register_script_function(func_endswith, "endswith")
|
||||
register_script_function(func_truncate, "truncate")
|
||||
register_script_function(func_swapprefix, "swapprefix", check_argcount=False)
|
||||
register_script_function(func_delprefix, "delprefix", check_argcount=False)
|
||||
|
||||
Reference in New Issue
Block a user