functionword_atpure
pure logical function word_at(s, at, word)
True if whole word word is at position at of s.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| s | character(len=*) | in | the text | |
| at | integer | in | the position | |
| word | character(len=*) | in | the word |
Result
| Name | Type | Attributes | Description |
|---|---|---|---|
| word_at | logical |
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