Test if text ends with str
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | text | Text to search |
||
character(len=*), | intent(in) | :: | str | String to look for |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module.
function endsWith(text,str) result(o)
!! Test if text ends with str
character(*),intent(in)::text
!! Text to search
character(*),intent(in)::str
!! String to look for
logical::o
integer::k
if(len(str)==0) then
o = .true.
else if(len(text)==0) then
o = .false.
else
k = len(text)
o = text(k-len(str)+1:k)==str
end if
end function endsWith