Skip to content

Commit

Permalink
Update substring invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
atuonufure committed Aug 15, 2023
1 parent 002bba0 commit c29df47
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions fhirpathpy/engine/invocations/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ def index_of(ctx, coll, substr):

def substring(ctx, coll, start, length=None):
string = ensure_string_singleton(coll)

if isinstance(start, list) or start is None:
return []

start = int(start)
if start < 0 or start >= len(string):
return []

if length is None:
if length is None or length == []:
return string[start:]

length = int(length)
return string[start : start + length]
return string[start : start + int(length)]


def starts_with(ctx, coll, prefix):
Expand Down

0 comments on commit c29df47

Please sign in to comment.