fdoc

functionword_atpure

pure logical function word_at(s, at, word)

True if whole word word is at position at of s.

Arguments

NameTypeIntentAttributesDescription
scharacter(len=*)in

the text

atintegerin

the position

wordcharacter(len=*)in

the word

Result

NameTypeAttributesDescription
word_atlogical

Source

Show the code
pure logical function word_at(s, at, word)
    character(len=*), intent(in) :: s       !! the text
    integer, intent(in) :: at               !! the position
    character(len=*), intent(in) :: word    !! the word
    character(len=*), parameter :: NAME_CHARS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'

    word_at = .false.
    if (at + len(word) - 1 > len(s)) return
    if (s(at:at + len(word) - 1) /= word) return
    word_at = .true.
    if (at + len(word) <= len(s)) word_at = index(NAME_CHARS, s(at + len(word):at + len(word))) == 0
    if (word_at .and. at > 1) word_at = index(NAME_CHARS, s(at - 1:at - 1)) == 0
end function word_at

Graphs

Called by