sscan_string_string Function

private elemental function sscan_string_string(self, 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.

 type(string) :: string1
 type(string) :: string2
 logical      :: test_passed(2)
 string1 = 'Hello World Hello!'
 string2 = 'llo'
 test_passed(1) = string1%scan(set=string2)==scan(string='Hello World Hello!', set='llo')
 test_passed(2) = string1%scan(set=string2, back=.true.)==scan(string='Hello World Hello!', set='llo', back=.true.)
 print '(L1)', all(test_passed)

Type Bound

string

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The 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~~sscan_string_string~~CalledByGraph proc~sscan_string_string stringifor_string_t::string%sscan_string_string interface~scan stringifor_string_t::scan interface~scan->proc~sscan_string_string

Contents

Source Code


Source Code

   elemental function sscan_string_string(self, 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
   !< type(string) :: string2
   !< logical      :: test_passed(2)
   !< string1 = 'Hello World Hello!'
   !< string2 = 'llo'
   !< test_passed(1) = string1%scan(set=string2)==scan(string='Hello World Hello!', set='llo')
   !< test_passed(2) = string1%scan(set=string2, back=.true.)==scan(string='Hello World Hello!', set='llo', back=.true.)
   !< print '(L1)', all(test_passed)
   !<```
   !=> T <<<
   class(string), intent(in)           :: self  !< The 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(self%raw).and.allocated(set%raw)) then
     i = scan(string=self%raw, set=set%raw, back=back)
   else
     i = 0
   endif
   endfunction sscan_string_string