Manual Reference Pages  - clip (3m_strings)

NAME

clip(3f) - [M_strings:WHITESPACE] trim leading and trailing blanks or set of characters from a string (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Returns
Examples
Author
License

SYNOPSIS

function clip(strin,set) result (strout)

    character(len=*),intent(in)          :: strin
    character(len=*),intent(in),optional :: set
    character(len=:),allocatable         :: strout

DESCRIPTION

leading and trailing spaces or set of characters are trimmed from the input string.

OPTIONS

strin input string to trim leading and trailing characters from
set set of characters to trim. Defaults to a space.

RETURNS

strout clipped version of input string

EXAMPLES

Sample program:

   program demo_clip
   use M_strings, only: clip
   implicit none
   character(len=20) ::  untrimmed = ’   ABCDEFG abcdefg  ’
      write(*,*) ’untrimmed string=[’,untrimmed,’]’
      write(*,*) ’clipped string=[’,clip(untrimmed),’]’
      ! which is equivalent to
      write(*,*) ’clipped string=[’,trim(adjustl(untrimmed)),’]’
      write(*,*)’non-space:’
      write(*,*) ’[’//clip(’----single-character----’,set=’-’)//’]’
      write(*,*) ’[’//clip(’  ... . .multi-character . ...’,set=’. ’)//’]’
   end program demo_clip

Results:

      >  untrimmed string=[   ABCDEFG abcdefg  ]
      >  clipped string=[ABCDEFG abcdefg]
      >  clipped string=[ABCDEFG abcdefg]
      >  non-space:
      >  [single-character]
      >  [multi-character]

AUTHOR

John S. Urban

LICENSE

Public Domain


Nemo Release 3.1 clip (3m_strings) July 20, 2024
Generated by manServer 1.08 from 3330a49b-3b50-4025-8190-f97396b6e2d4 using man macros.