matching_delimiter(3f) - [M_strings:QUOTES] find position of matching delimiter (LICENSE:PD)
Synopsis
Description
Options
Examples
Author
License
impure elemental subroutine matching_delimiter(str,ipos,imatch)
character(len=*),intent(in) :: str integer,intent(in) :: ipos integer,intent(out) :: imatch
Sets imatch to the position in string of the delimiter matching the delimiter in position ipos. Allowable delimiters are (), [], {}, <>.
str input string to locate delimiter position in ipos position of delimiter to find match for imatch location of matching delimiter. If no match is found, zero (0) is returned.
Sample program:
program demo_matching_delimiter use M_strings, only : matching_delimiter implicit none character(len=128) :: str integer :: imatchstr=’ a [[[[b] and ] then ] finally ]’ write(*,*)’string=’,str call matching_delimiter(str,1,imatch) write(*,*)’location=’,imatch call matching_delimiter(str,4,imatch) write(*,*)’location=’,imatch call matching_delimiter(str,5,imatch) write(*,*)’location=’,imatch call matching_delimiter(str,6,imatch) write(*,*)’location=’,imatch call matching_delimiter(str,7,imatch) write(*,*)’location=’,imatch call matching_delimiter(str,32,imatch) write(*,*)’location=’,imatch
end program demo_matching_delimiter
John S. Urban
Public Domain
Nemo Release 3.1 | matching_delimiter (3m_strings) | January 10, 2025 |