This module defines general procedures for string operations for both CHARACTER and TYPE(STRING_T) variables
Module naming
License: Public Domain Changes a string to upprtcase over optional specified column range Author: Milan Curcic Computes the first and last indices of tokens in input string, delimited by the characters in set, and stores them into first and last output arrays. Author: Federico Perini Computes the first and last indices of lines in input string, delimited by either CR, LF, or CRLF, and stores them into first and last output arrays. Author: Milan Curcic If back is absent, computes the leftmost token delimiter in string whose position is > pos. If back is present and true, computes the rightmost token delimiter in string whose position is < pos. The result is stored in pos.
Add one element to a string array with a loop (gcc-15 bug on array initializer)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(string_t), | intent(inout), | allocatable | :: | list(:) | ||
| type(string_t), | intent(in) | :: | new | 
Add elements to a string array with a loop (gcc-15 bug on array initializer)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(string_t), | intent(inout), | allocatable | :: | list(:) | ||
| type(string_t), | intent(in) | :: | new(:) | 
Hash a character(*) string of default kind
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | input | |||
| integer(kind=int64), | intent(in), | optional | :: | seed | 
Hash a string_t array of default kind
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(string_t), | intent(in) | :: | input(:) | |||
| integer(kind=int64), | intent(in), | optional | :: | seed | 
Determine total trimmed length of string_t array
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(string_t), | intent(in) | :: | string | 
Determine total trimmed length of string_t array
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(string_t), | intent(in) | :: | strings(:) | 
Check if array of TYPE(STRING_T) matches a particular CHARACTER string
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | search_string | |||
| type(string_t), | intent(in) | :: | array(:) | 
Check that two string objects are exactly identical
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(string_t), | intent(in) | :: | this | two strings to be compared | ||
| type(string_t), | intent(in) | :: | that | two strings to be compared | 
Check that two allocatable string object arrays are exactly identical
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(string_t), | intent(in), | allocatable | :: | this(:) | two string arrays to be compared | |
| type(string_t), | intent(in), | allocatable | :: | that(:) | two string arrays to be compared | 
increase the size of a TYPE(STRING_T) array by N elements
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(string_t), | intent(inout), | allocatable | :: | list(:) | Instance of the array to be resized | |
| integer, | intent(in), | optional | :: | n | Dimension of the final array size | 
Converts integer “i” to string
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | i | 
Converts integer “i” to string
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(in) | :: | i | 
Converts logical “l” to string
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| logical, | intent(in) | :: | l | 
test if a CHARACTER string ends with a specified suffix
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | s | |||
| character(len=*), | intent(in) | :: | e | 
test if a CHARACTER string ends with any of an array of suffixs
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | s | |||
| character(len=*), | intent(in) | :: | e(:) | 
Test if a CHARACTER string ends with any of an array of string suffixs
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | s | |||
| type(string_t), | intent(in) | :: | e(:) | 
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| character(len=:), | public, | allocatable | :: | s | 
| private function new_string_t (s) | Helper function to generate a new string_t instance (Required due to the allocatable component) | 
Sample program:
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | instr | 
return Fortran character variable when given a C-like array of single characters terminated with a C_NULL_CHAR character
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=1), | intent(in) | :: | c_string(:) | 
glob(3f) compares given STRING for match to PATTERN which may contain wildcard characters.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*) | :: | tame | A string without wildcards to compare to the globbing expression | |||
| character(len=*) | :: | wild | A (potentially) corresponding string with wildcards | 
result of test
Check that a module name is prefixed with a custom prefix: 1) It must be a valid FORTRAN name subset (<=63 chars, begin with letter, only alphanumeric allowed) 2) It must begin with the prefix 3) If longer, package name must be followed by default separator (“_”) plus at least one char
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(string_t), | intent(in) | :: | module_name | |||
| type(string_t), | intent(in) | :: | custom_prefix | 
Check that a module name is prefixed with the default package prefix: 1) It must be a valid FORTRAN name (<=63 chars, begin with letter, “_” is only allowed non-alphanumeric) 2) It must begin with the package name 3) If longer, package name must be followed by default separator plus at least one char
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(string_t), | intent(in) | :: | module_name | |||
| type(string_t), | intent(in) | :: | package_name | 
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | line | 
Check if feature name is valid (alphanumeric, underscore, dash allowed)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | name | 
Check that a module name fits the current naming rules: 1) It must be a valid FORTRAN name (<=63 chars, begin with letter, “_” is only allowed non-alphanumeric) 2) It must begin with the package name 3) If longer, package name must be followed by default separator plus at least one char
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(string_t), | intent(in) | :: | module_name | |||
| type(string_t), | intent(in) | :: | package_name | |||
| type(string_t), | intent(in) | :: | custom_prefix | |||
| logical, | intent(in) | :: | enforce_module_names | 
Check that a custom module prefix fits the current naming rules: 1) Only alphanumeric characters (no spaces, dashes, underscores or other characters) 2) Does not begin with a number (Fortran-compatible syntax)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(string_t), | intent(in) | :: | module_prefix | 
JOIN(3f) appends the elements of a CHARACTER array into a single CHARACTER variable, with elements 1 to N joined from left to right. By default each element is trimmed of trailing spaces and the default separator is a null string.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | str(:) | |||
| character(len=*), | intent(in), | optional | :: | sep | ||
| logical, | intent(in), | optional | :: | trm | ||
| character(len=*), | intent(in), | optional | :: | left | ||
| character(len=*), | intent(in), | optional | :: | right | ||
| character(len=*), | intent(in), | optional | :: | start | ||
| character(len=*), | intent(in), | optional | :: | end | 
Changes a string to lowercase over optional specified column range
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | str | |||
| integer, | intent(in), | optional | :: | begin | ||
| integer, | intent(in), | optional | :: | end | 
Returns string with characters in charset replaced with target_char.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | string | |||
| character(len=1), | intent(in) | :: | charset(:) | |||
| character(len=1), | intent(in) | :: | target_char | 
test if a CHARACTER string begins with a specified prefix
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | s | |||
| character(len=*), | intent(in) | :: | e | |||
| logical, | intent(in), | optional | :: | case_sensitive | 
Check if array of TYPE(STRING_T) matches a particular CHARACTER string
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | search_string | |||
| type(string_t), | intent(in) | :: | array(:) | 
Concatenate an array of type(string_t) into a single CHARACTER variable
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(string_t), | intent(in) | :: | strings(:) | |||
| character(len=*), | intent(in), | optional | :: | delim | 
Returns string with special characters replaced with an underscore. For now, only a hyphen is treated as a special character, but this can be expanded to other characters if needed.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | string | 
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | str | |||
| integer, | intent(in), | optional | :: | begin | ||
| integer, | intent(in), | optional | :: | end | 
notabs(3f) - [fpm_strings:NONALPHA] expand tab characters (LICENSE:PD)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | instr | |||
| character(len=*), | intent(out) | :: | outstr | |||
| integer, | intent(out) | :: | ilen | 
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=:), | intent(inout), | allocatable | :: | string | ||
| character(len=*), | intent(in) | :: | set | |||
| character(len=1), | intent(in), | optional | :: | replace_with | 
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(string_t), | intent(inout) | :: | string | 
parse string on delimiter characters and store tokens into an allocatable array given a line of structure ” par1 par2 par3 … parn ” store each par(n) into a separate variable in array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | input_line | input string to tokenize | ||
| character(len=:), | intent(out), | allocatable | :: | array(:) | output array of tokens | |
| character(len=*), | intent(in), | optional | :: | delimiters | list of delimiter characters | |
| character(len=*), | intent(in), | optional | :: | order | order of output array sequential|[reverse|right] | |
| character(len=*), | intent(in), | optional | :: | nulls | return strings composed of delimiters or not ignore|return|ignoreend | 
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | string | |||
| character(len=*), | intent(in) | :: | set | |||
| integer, | intent(out), | allocatable | :: | first(:) | ||
| integer, | intent(out), | allocatable | :: | last(:) | 
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | string | |||
| integer, | intent(out), | allocatable | :: | first(:) | ||
| integer, | intent(out), | allocatable | :: | last(:) |