[UP]


Manual Reference Pages  - M_strings (3)

NAME

M_strings(3f) - [M_strings:INTRO] Fortran string module

CONTENTS

Description
Synopsis
See Also
Examples
Author
License

DESCRIPTION

The M_strings(3fm) module is a collection of Fortran procedures that supplement the built-in intrinsic string routines. Routines for parsing, tokenizing, changing case, substituting new strings for substrings, locating strings with simple wildcard expressions, removing tabs and line terminators and other string manipulations are included.

M_strings_oop(3fm) is a companion module that provides an OOP interface to the M_strings module.

SYNOPSIS

public entities:

     use M_strings, only : split,sep,delim,chomp
     use M_strings, only : substitute,change,modif,transliterate,reverse
     use M_strings, only : replace,join
     use M_strings, only : upper,lower,upper_quoted
     use M_strings, only : rotate13
     use M_strings, only : adjustc,compact,nospace,indent
     use M_strings, only : crop,unquote,quote
     use M_strings, only : len_white,atleast,stretch,lenset,merge_str
     use M_strings, only : switch,s2c,c2s
     use M_strings, only : noesc,notabs,dilate,expand,visible
     !!use M_strings, only : uc
     use M_strings, only : string_to_value,string_to_values,s2v,s2vs
     use M_strings, only : value_to_string,v2s,msg
     use M_strings, only : listout,getvals
     use M_strings, only : glob, ends_with
     use M_strings, only : fmt
     use M_strings, only : base, decodebase, codebase
     use M_strings, only : isalnum, isalpha, iscntrl, isdigit
     use M_strings, only : isgraph, islower, isprint, ispunct
     use M_strings, only : isspace, isupper, isascii, isblank, isxdigit
     use M_strings, only : fortran_name

    TOKENS

split subroutine parses string using specified delimiter characters and stores tokens into an array
sep function interface to split(3f)
delim subroutine parses string using specified delimiter characters and store tokens into an array
chomp function consumes input line as it returns next token in a string using specified delimiters
fmt convert a string into a paragraph

    EDITING

substitute
  subroutine non-recursively globally replaces old substring with new substring
replace
  function non-recursively globally replaces old substring with new substring using allocatable string (version of substitute(3f) without limitation on length of output string)
change subroutine non-recursively globally replaces old substring with new substring with a directive like line editor
modif subroutine modifies a string with a directive like the XEDIT line editor MODIFY command
transliterate
  replace characters found in set one with characters from set two
reverse
  reverse character order in a string
join join an array of CHARACTER variables with specified separator
rotate13
  apply trivial encryption algorithm ROT13 to a string

    CASE

upper function converts string to uppercase
lower function converts string to miniscule
upper_quoted
  function converts string to uppercase skipping strings quoted per Fortran rules

    WHITE SPACE

adjustc
  elemental function centers text within the length of the input string
compact
  left justify string and replace duplicate whitespace with single characters or nothing
nospace
  function replaces whitespace with nothing
indent find number of leading spaces
crop function trims leading and trailing spaces

    QUOTES

unquote
  remove quotes from string as if read with list-directed input
quote add quotes to string as if written with list-directed input

    STRING LENGTH

len_white
  find location of last non-whitespace character
lenset return a string of specified length
atleast
  return a string of at least specified length
stretch
  return a string of at least specified length with suffix
merge_str
  make strings of equal length and then call MERGE(3f) intrinsic

    CHARACTER ARRAY VERSUS STRING

switch switch between a string and an array of single characters
s2c convert string to array of single characters and add null terminator for passing to C
c2s convert null-terminated array of single characters to string for converting strings returned from C

    NONALPHA

noesc convert non-printable ASCII8 characters to a space
notabs convert tabs to spaces while maintaining columns, assuming tabs are set every 8 characters
dilate function to convert tabs to spaces assuming tabs are set every 8 characters
expand expand escape sequences in a string
visible
  expand escape sequences in a string to control and meta-control representations

    NUMERIC STRINGS

string_to_value
  generic subroutine returns numeric value (REAL, DOUBLEPRECISION, INTEGER) from string
string_to_values
  subroutine reads an array of numbers from a string
getvals
  subroutine reads a relatively arbitrary number of values from a string using list-directed read
s2v function returns DOUBLEPRECISION numeric value from string
s2vs function returns a DOUBLEPRECISION array of numbers from a string
msg append the values of up to nine values into a string
value_to_string
  generic subroutine returns string given numeric value (REAL, DOUBLEPRECISION, INTEGER, LOGICAL )
v2s generic function returns string from numeric value (REAL, DOUBLEPRECISION, INTEGER )
listout
  expand a list of numbers where negative numbers denote range ends (1 -10 means 1 thru 10)
isnumber
  determine if string represents a number

    CHARACTER TESTS

glob compares given string for match to pattern which may contain wildcard characters
ends_with
  test whether strings ends with one of the specified suffixs
o isalnum returns .true. if character is a letter or digit
o isalpha returns .true. if character is a letter and
o iscntrl returns .true. if character is a delete character or ordinary control character
o isdigit returns .true. if character is a digit (0,1,...,9) and .false. otherwise
o isgraph returns .true. if character is a printable character except a space is considered non-printable
o islower returns .true. if character is a miniscule letter (a-z)
o isprint returns .true. if character is an ASCII printable character
o ispunct returns .true. if character is a printable punctuation character
o isspace returns .true. if character is a null, space, tab, carriage return, new line, vertical tab, or formfeed
o isupper returns .true. if character is an uppercase letter (A-Z)
o isascii returns .true. if the character is in the range char(0) to char(127)
o isblank returns .true. if character is a blank character (space or horizontal tab.
o isxdigit returns .true. if character is a hexadecimal digit (0-9, a-f, or A-F).
fortran_name
  returns .true. if input string is a valid Fortran name

    BASE CONVERSION

base
  convert whole number string in base [2-36] to string in alternate base [2-36]
codebase
  convert whole number string in base [2-36] to base 10 number decodebase convert whole number in base 10 to string in base [2-36]

    MISCELLANEOUS

describe
  returns a string describing the name of a single character

    INTRINSICS

The M_strings(3fm) module supplements and works in combination with the Fortran built-in intrinsics. Stand-alone Fortran lets you access the characters in a string using ranges much like they are character arrays, assignment, comparisons with standard operators, supports dynamically allocatable strings and supports concatenation using the // operator, as well as a number of intrinsic string routines:

       adjustl             Left adjust a string
       adjustr             Right adjust a string
       index               Position of a substring within a string
       repeat              Repeated string concatenation
       scan                Scan a string for the presence of a set
                           of characters
       trim                Remove trailing blank characters of a string
       verify              Scan a string for the absence of a set of
                           characters
       len                 It returns the length of a character string
       achar               converts an integer into a character
       iachar              converts a character into an integer
       len_trim            finds length of string with trailing spaces
                           ignored
       new_line            Newline character
       selected_char_kind  Choose character kind
       lge                 Lexical greater than or equal
       lgt                 Lexical greater than
       lle                 Lexical less than or equal
       llt                 Lexical less than

    OOPS INTERFACE

The M_strings_oop(3fm) module (included with the M_strings(3fm) module) provides an OOP (Object-Oriented Programming) interface to the M_strings(3fm) module.

SEE ALSO

There are additional routines in other GPF modules for working with expressions (M_calculator), time strings (M_time), random strings (M_random, M_uuid), lists (M_list), and interfacing with the C regular expression library (M_regex).

EXAMPLES

Each of the procedural functions includes an example program in the corresponding man(1) page for the function. The object-oriented interface does not have individual man(1) pages, but is instead demonstrated using the following example program:

    program demo_M_strings
    use M_strings, only : split, delim, chomp, sep
    use M_strings, only : substitute, change, modif
    use M_strings, only : transliterate, reverse
    use M_strings, only : replace, join
    use M_strings, only : upper, lower, upper_quoted
    use M_strings, only : rotate13
    use M_strings, only : adjustc, compact, nospace, indent, crop
    use M_strings, only : unquote, quote
    use M_strings, only : len_white, atleast, stretch, lenset, merge_str
    use M_strings, only : switch, s2c, c2s
    use M_strings, only : noesc, notabs, dilate, expand, visible
    !!use M_strings, only : uc
    use M_strings, only : string_to_value, string_to_values, s2v, s2vs
    use M_strings, only : value_to_string, v2s, msg
    use M_strings, only : listout, getvals
    use M_strings, only : glob, ends_with
    use M_strings, only : fmt
    use M_strings, only : base, decodebase, codebase
    use M_strings, only : isalnum, isalpha, iscntrl, isdigit, isgraph
    use M_strings, only : islower, isprint, ispunct, isspace, isupper
    use M_strings, only : isascii, isblank, isxdigit
    use M_strings, only : fortran_name
    end program demo_M_strings

Expected output

AUTHOR

John S. Urban

LICENSE

Public Domain


M_strings (3) March 11, 2021
Generated by manServer 1.08 from cd6f9581-318e-4a5f-9edf-32661b39dd85 using man macros.