sindex_character_string Function

public elemental function sindex_character_string(string_, substring, back) result(i)

Arguments

Type IntentOptional AttributesName
character(kind=CK,len=*), intent(in) :: string_

The string.

type(string), intent(in) :: substring

Searched substring.

logical, intent(in), optional :: back

Start of the last occurrence rather than the first.

Return Value integer

Result of the search.

Description

Return the position of the start of the first occurrence of string substring as a substring in string, counting from one. If substring is not present in string, zero is returned. If the back argument is present and true, the return value is the start of the last occurrence rather than the first.

Called By

proc~~sindex_character_string~~CalledByGraph proc~sindex_character_string sindex_character_string interface~index index interface~index->proc~sindex_character_string
Help

Source Code

  elemental function sindex_character_string(string_, substring, back) result(i)
  !---------------------------------------------------------------------------------------------------------------------------------
  !< Return the position of the start of the first occurrence of string `substring` as a substring in `string`, counting from one.
  !< If `substring` is not present in `string`, zero is returned. If the back argument is present and true, the return value is
  !< the start of the last occurrence rather than the first.
  !---------------------------------------------------------------------------------------------------------------------------------
  character(kind=CK, len=*), intent(in)           :: string_   !< The string.
  type(string),              intent(in)           :: substring !< Searched substring.
  logical,                   intent(in), optional :: back      !< Start of the last occurrence rather than the first.
  integer                                         :: i         !< Result of the search.
  !---------------------------------------------------------------------------------------------------------------------------------

  !---------------------------------------------------------------------------------------------------------------------------------
  if (allocated(substring%raw)) then
    i = index(string=string_, substring=substring%raw, back=back)
  else
    i = 0
  endif
  return
  !---------------------------------------------------------------------------------------------------------------------------------
  endfunction sindex_character_string