[UP]


Manual Reference Pages  - sep (3)

NAME

sep(3f) - [M_strings:TOKENS] function to parse string into an array using specified delimiters (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Returns
Examples
Author
License

SYNOPSIS

function sep(input_line,delimiters,nulls)

    character(len=*),intent(in)              :: input_line
    character(len=*),optional,intent(in)     :: delimiters
    character(len=*),optional,intent(in)     :: nulls
    character(len=:),allocatable             :: sep(:)

DESCRIPTION

sep(3f) parses a string using specified delimiter characters and store tokens into an allocatable array

OPTIONS

INPUT_LINE
  Input string to tokenize
DELIMITERS
  List of delimiter characters. The default delimiters are the "whitespace" characters (space, tab,new line, vertical tab, formfeed, carriage return, and null). You may specify an alternate set of delimiter characters.

Multi-character delimiters are not supported (Each character in the DELIMITERS list is considered to be a delimiter).

Quoting of delimiter characters is not supported.

NULLS=IGNORE|RETURN|IGNOREEND
  Treatment of null fields. By default adjacent delimiters in the input string do not create an empty string in the output array. if NULLS=’return’ adjacent delimiters create an empty element in the output ARRAY. If NULLS=’ignoreend’ then only trailing delimiters at the right of the string are ignored.

RETURNS

SEP Output array of tokens

EXAMPLES

Sample program:

   program demo_sep
   use M_strings, only: sep
   character(len=*),parameter :: fo=’(/,a,*(/,"[",g0,"]":,","))’
   character(len=*),parameter :: line=&
   ’  aBcdef   ghijklmnop qrstuvwxyz  1:|:2     333|333 a B cc    ’
      write(*,’(a)’) ’INPUT LINE:[’//LINE//’]’
      write(*,fo) ’typical call:’,sep(line)
      write(*,fo) ’delimiters ":|":’,sep(line,’:|’)
      write(*,fo) ’count null fields ":|":’,sep(line,’:|’,’return’)
   end program demo_sep

Output

   INPUT LINE:[  aBcdef   ghijklmnop qrstuvwxyz  1:|:2     333|333 a B cc    ]

typical call: [cc ], [B ], [a ], [333|333 ], [1:|:2 ], [qrstuvwxyz], [ghijklmnop], [aBcdef ]

delimiters ":|": [333 a B cc ], [2 333 ], [ aBcdef ghijklmnop qrstuvwxyz 1]

count null fields ":|": [333 a B cc ], [2 333 ], [ ], [ ], [ aBcdef ghijklmnop qrstuvwxyz 1]

AUTHOR

John S. Urban

LICENSE

Public Domain


sep (3) March 11, 2021
Generated by manServer 1.08 from 136f5a69-2354-432f-a140-970870edb5b8 using man macros.