Checks if a string starts with a given substring. It can be an array of string.
l = startsWith(str, substr)
Where:
str
: String that the user wants to check how it starts. It can be an array.substr
: Substring to search for to check if str starts with it.It returns True if the string starts 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 starts with a substring:
PROGRAM startsWithExample
USE FU_Strings, ONLY: startsWith
IMPLICIT NONE
CHARACTER(LEN=:), ALLOCATABLE :: text1, text2
text1 = 'String1'
text2 = 'St'
IF (startsWith(text1, text2)) THEN
WRITE(*,*) 'String starts with St'
ELSE
WRITE(*,*) 'String does not start with St'
END IF
END PROGRAM startsWithExample
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | str |
String that the user wants to check how it starts. It can be an array. |
||
character(len=*), | intent(in) | :: | substr |
Substring to search to check if str starts with it. |
True if the string starts 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.