SUB(3f) - [M_unicode:EDITING] Return substring (LICENSE:MIT)
Synopsis
Description
Options
Returns
Examples
See Also
Author
License
impure elemental function sub(str,left,right,step) result(section)
type(unicode_type) :: str integer,intent(in),optional :: left integer,intent(in),optional :: right integer,intent(in),optional :: step
sub(3f) returns a substring from one column to another.
str the input string to return a section of left column number of str starting section of str to return. Defaults to 1 when STEP is positive, or right end of STR when STEP is negative. right column number of str ending section of str to return. Defaults to right end of STR when STEP is positive, or 1 when STEP is negative. step step to take from left column to right column. Defaults to 1.
out The specified subsection of the input string
Sample Program:
program demo_sub use M_unicode, only : sub, assignment(=) use M_unicode, only : len use M_unicode, only : ut=> unicode_type implicit none type(ut) :: string type(ut) :: piece ! string=abcdefghij ! piece=sub(string,3,5) call printme(selected range:) piece=sub(string,6) call printme(from character to end:) piece=sub(string,5,5) call printme(single character:) piece=sub(string,step=-1) call printme(reverse string:) contains subroutine printme(label) character(len=*),intent(in) :: label write(*,(a,"[",g0,"]",/)) label, piece%character() end subroutine printme end program demo_subResults: > selected range:[cde] > > from character to end:[fghij] > > single character:[e] > > reverse string:[jihgfedcba] >
adjustl(3f), adjustr(3f), repeat(3f), trim(3f), len_trim(3f), len(3f)
John S. Urban
