is_number Function

private elemental function is_number(self, allow_spaces)

Arguments

Type IntentOptional AttributesName
class(string), intent(in) :: self

The string.

logical, intent(in), optional :: allow_spaces

Allow leading-trailing spaces.

Return Value logical

Result of the test.

Description

Return true if the string contains a number (real or integer).


Source Code

  elemental function is_number(self, allow_spaces)
  !---------------------------------------------------------------------------------------------------------------------------------
  !< Return true if the string contains a number (real or integer).
  !---------------------------------------------------------------------------------------------------------------------------------
  class(string), intent(in)           :: self         !< The string.
  logical,       intent(in), optional :: allow_spaces !< Allow leading-trailing spaces.
  logical                             :: is_number    !< Result of the test.
  !---------------------------------------------------------------------------------------------------------------------------------

  !---------------------------------------------------------------------------------------------------------------------------------
  is_number = (self%is_integer(allow_spaces=allow_spaces).or.self%is_real(allow_spaces=allow_spaces))
  return
  !---------------------------------------------------------------------------------------------------------------------------------
  endfunction is_number