sverify_character_string Function

private elemental function sverify_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 not in set. If all characters of string are found in set, the result is zero.

 type(string) :: string1
 logical      :: test_passed(2)
 string1 = 'ell'
 test_passed(1) = verify(s='Hello World Hello!', set=string1)==verify(string='Hello World Hello!', set='llo')
 test_passed(2) = verify(s='Hello World Hello!', set=string1, back=.true.)==verify(string='Hello World Hello!', set='llo', &
                                                                                   back=.true.)
 print '(L1)', all(test_passed)

Arguments

Type IntentOptional Attributes Name
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.

Return Value integer

Result of the search.


Called by

proc~~sverify_character_string~~CalledByGraph proc~sverify_character_string stringifor_string_t::sverify_character_string interface~verify stringifor_string_t::verify interface~verify->proc~sverify_character_string

Contents


Source Code

   elemental function sverify_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 not
   !< in `set`. If all characters of `string` are found in `set`, the result is zero.
   !<
   !<```fortran
   !< type(string) :: string1
   !< logical      :: test_passed(2)
   !< string1 = 'ell'
   !< test_passed(1) = verify(s='Hello World Hello!', set=string1)==verify(string='Hello World Hello!', set='llo')
   !< test_passed(2) = verify(s='Hello World Hello!', set=string1, back=.true.)==verify(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 = verify(string=s, set=set%raw, back=back)
   else
     i = 0
   endif
   endfunction sverify_character_string