sscan_character_string Function

private elemental function sscan_character_string(s, set, back) result(i)

Arguments

TypeIntentOptionalAttributesName
character(kind=CK,len=*), intent(in) :: s
type(string), intent(in) :: set
logical, intent(in), optional :: back

Return Value integer


Called by

proc~~sscan_character_string~2~~CalledByGraph proc~sscan_character_string~2 sscan_character_string interface~scan~2 scan interface~scan~2->proc~sscan_character_string~2

Contents


Source Code

   elemental function sscan_character_string(s, set, back) result(i)
   !< Return the leftmost (if `back` is either absent or equals false, otherwise the rightmost) character of string that is in `set`.
   !<
   !<```fortran
   !< type(string) :: string1
   !< logical      :: test_passed(2)
   !< string1 = 'llo'
   !< test_passed(1) = scan(s='Hello World Hello!', set=string1)==scan(string='Hello World Hello!', set='llo')
   !< test_passed(2) = scan(s='Hello World Hello!', set=string1, back=.true.)==scan(string='Hello World Hello!', &
   !<                                                                               set='llo', back=.true.)
   !< print '(L1)', all(test_passed)
   !<```
   !=> T <<<
   character(kind=CK, len=*), intent(in)           :: s    !< String.
   type(string),              intent(in)           :: set  !< Searched set.
   logical,                   intent(in), optional :: back !< Start of the last occurrence rather than the first.
   integer                                         :: i    !< Result of the search.

   if (allocated(set%raw)) then
     i = scan(string=s, set=set%raw, back=back)
   else
     i = 0
   endif
   endfunction sscan_character_string