Checks if a string ends with a given substring. It can be an array of string.
l = endsWith(str, substr)
Where:
str
: String that the user wants to check how it ends. It can be an array.substr
: Substring to search for to check if str ends with it.It returns True if the string ends with the substring and False otherwise. If substr is empty it returns True. If the input is an array, the returned values will also be in an array.
The following program checks if a string ends with a substring:
PROGRAM endsWithExample
USE FU_Strings, ONLY: endsWith
IMPLICIT NONE
CHARACTER(LEN=:), ALLOCATABLE :: text1, text2
text1 = 'String1'
text2 = 'g1'
IF (endsWith(text1, text2)) THEN
WRITE(*,*) 'String ends with g1'
ELSE
WRITE(*,*) 'String does not end with g1'
END IF
END PROGRAM endsWithExample
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | str |
String that the user wants to check how it ends. It can be an array. |
||
character(len=*), | intent(in) | :: | substr |
Substring to search to check if str ends with it. |
True if the string ends with the substring and False otherwise. If substr is empty it returns True. If the input is an array, the returned values will also be in an array.