flibs/strings - String operations
The string_operations module implements a variety of string operations based on allocatable-length strings. The advantage is that the result can always be stored, instead of the user having to supply strings with sufficient length from the outset.
The module defines routines to replace substrings, to insert or delete them and several others others. The replace subroutine may be used to replace several substrings in one call.
To import the definitions, use this module.
A derived type used by replace to define which substrings to replace by others:
result = replace( 'RYeplace StRings', [pair('RY', 'XXXX'), pair('R', 'YY')] )
This will replace the substring "RY" by "XXXX" and any substring "R" that is left by "YY".
Replace the substring in the input string by the new string. The argument mode controls what substrings are exactly replaced. The result is an allocatable-length character string.
The input string which is to be edited.
The substring which is to be replaced.
The string which is to replace the substring.
The replacement mode. This argument is optional, if left out it defaults to "replace all".
replace_all specifies that all occurrences are to be replaced.
first_only specifies that only the first occurrence is to be replaced.
last_only specifies that only the last occurrence is to be replaced.
Replace several substrings at once. The substrings are sought one after another. The substring first in the input string that matches is replaced and then the next is sought. The procedure stops when all matches have been taken care of. Note that replaced substrings do not cause new matches.
The input string which is to be edited.
The substrings to be relpaced and the strings they shoudl replaced by.
Insert a string at a given position into a string.
The input string which is to be edited.
The position at which the string is to be inserted. Two special values:
prepend specifies that new string should come at the very start.
append specifies that new string should be appended.
The string to be inserted.
Delete a substring of given length.
The input string which is to be edited.
The first position that is to be deleted.
The length of the substring to be deleted.
Return a string with all lower case letters.
The input string which is to be edited.
Return a string with all upper case letters.
The input string which is to be edited.
Return a string with all trailing characters in the given set removed. It is an extension of the trim() intrinsic function.
The input string which is to be edited.
The set of characters that should be removed at the end.
Return a string with all leading characters in the given set removed. It is an extension of the trim() intrinsic function.
The input string which is to be edited.
The set of characters that should be removed at the start.
Read a complete line from a file, regardless of the length.
Logical unit number of the file to be read.
The line of text that was read or an empty string if the end of the file was reached.
Indication whether the end of file was reached.
Copyright © 2019 Arjen Markus <arjenmarkus@sourceforge.net>