is_valid__regex Function

public function is_valid__regex(pattern, str, answer, substr) result(res)

This function checks if a pattern matches a string using the regex function and compares the result to the expected answer.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: pattern
character(len=*), intent(in) :: str
character(len=*), intent(in) :: answer
character(len=:), intent(inout), allocatable :: substr

Return Value logical


Source Code

   function is_valid__regex(pattern, str, answer, substr) result(res)
      implicit none
      character(*),              intent(in)    :: pattern, str
      character(*),              intent(in)    :: answer
      character(:), allocatable, intent(inout) :: substr

      character(:), allocatable :: local
      integer(int32)            :: length
      logical                   :: res

      call regex(pattern, str, local, length)
      substr = local

      res = local == answer

   end function is_valid__regex