Loading...
Searching...
No Matches
operator(.contains.)

Definition

Test whether a value is present in an array.

The .contains. operator provides convenient membership testing between arrays of intrinsic characters and arrays of string objects.

Supported combinations are:

  • string(:) .contains. string
  • string(:) .contains. character(*)
  • character(:) .contains. string
  • character(:) .contains. character(*)

The comparison uses the overloaded equality operator (==) associated with the involved types.

Examples

Arrays of string:

type(string) :: fruits(3)
fruits = [ string('apple'), &
string('banana'), &
string('cherry') ]
print *, fruits .contains. 'banana' ! .true.
print *, fruits .contains. 'orange' ! .false.

Mixed character/string usage:

character(10) :: names(2)
names = ['foo ', 'bar ']
print *, names .contains. string('foo') ! .true.

Empty arrays:

type(string) :: values(0)
print *, values .contains. 'x' ! .false.
Returns
.true. if the searched value is present, .false. otherwise.

Definition at line 323 of file string.f90.


The documentation for this interface was generated from the following file:

Methods

◆ characters_contain_character()

logical function characters_contain_character ( character(*), dimension(:), intent(in) lhs,
character(*), intent(in) rhs )

Checks whether an array of character contains a given character expression.

Parameters
[in]lhsarray of character
[in]rhscharacter expression to search for
Returns
.true. if rhs is present in lhs

Definition at line 972 of file string.f90.

◆ characters_contain_string()

logical function characters_contain_string ( character(*), dimension(:), intent(in) lhs,
type(string), intent(in) rhs )

Checks whether an array of character contains a given string.

Parameters
[in]lhsarray of character
[in]rhsstring to search for
Returns
.true. if rhs is present in lhs

Definition at line 993 of file string.f90.

◆ strings_contain_character()

logical function strings_contain_character ( type(string), dimension(:), intent(in) lhs,
character(*), intent(in) rhs )

Checks whether an array of string contains a given character expression.

Parameters
[in]lhsarray of string
[in]rhscharacter expression to search for
Returns
.true. if rhs is present in lhs

Definition at line 951 of file string.f90.

◆ strings_contain_string()

logical function strings_contain_string ( type(string), dimension(:), intent(in) lhs,
type(string), intent(in) rhs )

Checks whether an array of string contains a given string.

Parameters
[in]lhsarray of string
[in]rhsstring to search for
Returns
.true. if rhs is present in lhs

Definition at line 930 of file string.f90.