ends_with Interface

public interface ends_with

Contents


Module Procedures

private pure function ends_with_str(string, ending) result(matched)

NAME

ends_with(3f) - [M_strings:COMPARE] test if string ends with specified
                suffix(es)
(LICENSE:PD)

SYNOPSIS

function ends_with(source_string,suffix)

 or

function ends_with(source_string,[suffix])

 character(len=*),intent(in)          :: source_string
 character(len=*),intent(in)          :: suffix(..)
 logical                              :: ends_with

DESCRIPTION

OPTIONS

 SOURCE_STRING  string to tokenize
 SUFFIX         list of separator strings. May be scalar or an array.
                Trailing spaces are ignored.

RETURNS

 ENDS_WITH      returns .TRUE. if one of the suffix match the end
                of SOURCE_STRING.

EXAMPLES

Sample program:

program demo_ends_with
use M_strings, only : ends_with
use, intrinsic :: iso_fortran_env, only : stdout=>output_unit
implicit none
   write(stdout,*)ends_with('prog.a',['.o','.i','.s'])
   write(stdout,*)ends_with('prog.f90',['.F90','.f90','.f  ','.F  '])
   write(stdout,*)ends_with('prog.pdf','.pdf')
   write(stdout,*)ends_with('prog.doc','.txt')
end program demo_ends_with

Results:

 F
 T
 T
 F

AUTHOR

John S. Urban

LICENSE

Public Domain

Arguments

Type IntentOptional Attributes Name
character, intent(in) :: string
character, intent(in) :: ending

Return Value logical

private pure function ends_with_any(string, endings) result(matched)

Arguments

Type IntentOptional Attributes Name
character, intent(in) :: string
character, intent(in) :: endings(:)

Return Value logical