isalnum,isalpha,iscntrl,isdigit,isgraph,islower, isprint,ispunct,isspace,isupper, isascii,isblank,isxdigit(3f) - [M_strings:COMPARE] test membership in subsets of ASCII set (LICENSE:PD)
Synopsis
Description
Examples
Author
License
Where "FUNCNAME" is one of the function names in the group, the functions are defined by
elemental function FUNCNAME(onechar) character(len=*),intent(in) :: onechar logical :: FUNC_NAME
These elemental functions test if a character belongs to various subsets of the ASCII character set.
isalnum returns .true. if character is a letter (a-z,A-Z) or digit (0-9) isalpha returns .true. if character is a letter and [char46]false. otherwise isascii returns .true. if character is in the range char(0) to char(127) isblank returns .true. if character is a blank (space or horizontal tab). iscntrl returns .true. if character is a delete character or ordinary control character (0x7F or 0x00-0x1F). isdigit returns .true. if character is a digit (0,1,...,9) and .false. otherwise isgraph returns .true. if character is a printable ASCII character excluding space islower returns .true. if character is a miniscule letter (a-z) isprint returns .true. if character is a printable ASCII character ispunct returns .true. if character is a printable punctuation character (isgraph(c) && !isalnum(c)). isspace returns .true. if character is a null, space, tab, carriage return, new line, vertical tab, or formfeed isupper returns .true. if character is an uppercase letter (A-Z) isxdigit returns .true. if character is a hexadecimal digit (0-9, a-f, or A-F).
Sample Program:
program demo_isalnumExpected output:use M_strings, only : isalnum, isspace, switch implicit none character(len=10),allocatable :: string(:) character(len=1),allocatable :: letters(:) integer :: i string=[& & 1 2 3 4 5 ,& & letters ,& & 1234567890 ,& & <02468> ,& & has dot. ,& & both 8787 ] ! if string is all letters, digits and whitespace return .true. do i=1,size(string) letters=switch(string(i)) write(*,(*(g0))) For string[//string(i)//] , & all( isalnum(letters) .or. isspace(letters) ) enddo
end program demo_isalnum
> For string[1 2 3 4 5 ] T > For string[letters ] T > For string[1234567890] T > For string[<02468> ] F > For string[has dot. ] F > For string[both 8787 ] T
John S. Urban
Public Domain
