Functions on character and String values: case conversion, prefix and suffix tests, searching, and removing
given characters from both ends. The names and arguments follow the Fortran standard library (stdlib).
These are in a module of their own, separate from io_fortran_lib, so that adding them can't clash with a
procedure of the same name in a program that uses io_fortran_lib without an only list. Use it alongside:
use io_fortran_lib, only: String
use io_strings, only: to_upper, find
The same operations are type-bound procedures of String, such as s%to_upper().
For a user reference, see io_strings.
Interfaces
Converts the ASCII letters a to z to upper case. Other characters are unchanged.
-
private elemental recursive function to_upper_chars(string) result(res)
Arguments
| Type |
Intent | Optional | Attributes |
|
Name |
|
|
character(len=*),
|
intent(in) |
|
|
:: |
string |
|
Return Value
character(len=len)
-
private elemental recursive function to_upper_string(string) result(res)
Arguments
| Type |
Intent | Optional | Attributes |
|
Name |
|
|
type(String),
|
intent(in) |
|
|
:: |
string |
|
Return Value
type(String)
Converts the ASCII letters A to Z to lower case. Other characters are unchanged.
-
private elemental recursive function to_lower_chars(string) result(res)
Arguments
| Type |
Intent | Optional | Attributes |
|
Name |
|
|
character(len=*),
|
intent(in) |
|
|
:: |
string |
|
Return Value
character(len=len)
-
private elemental recursive function to_lower_string(string) result(res)
Arguments
| Type |
Intent | Optional | Attributes |
|
Name |
|
|
type(String),
|
intent(in) |
|
|
:: |
string |
|
Return Value
type(String)
Whether string starts with substring. Every string starts with the empty string.
-
private elemental recursive function starts_with_cc(string, substring) result(res)
Arguments
| Type |
Intent | Optional | Attributes |
|
Name |
|
|
character(len=*),
|
intent(in) |
|
|
:: |
string |
|
|
character(len=*),
|
intent(in) |
|
|
:: |
substring |
|
Return Value
logical
-
private elemental recursive function starts_with_cs(string, substring) result(res)
Arguments
| Type |
Intent | Optional | Attributes |
|
Name |
|
|
character(len=*),
|
intent(in) |
|
|
:: |
string |
|
|
type(String),
|
intent(in) |
|
|
:: |
substring |
|
Return Value
logical
-
private elemental recursive function starts_with_sc(string, substring) result(res)
Arguments
| Type |
Intent | Optional | Attributes |
|
Name |
|
|
type(String),
|
intent(in) |
|
|
:: |
string |
|
|
character(len=*),
|
intent(in) |
|
|
:: |
substring |
|
Return Value
logical
-
private elemental recursive function starts_with_ss(string, substring) result(res)
Arguments
| Type |
Intent | Optional | Attributes |
|
Name |
|
|
type(String),
|
intent(in) |
|
|
:: |
string |
|
|
type(String),
|
intent(in) |
|
|
:: |
substring |
|
Return Value
logical
Whether string ends with substring. Every string ends with the empty string.
-
private elemental recursive function ends_with_cc(string, substring) result(res)
Arguments
| Type |
Intent | Optional | Attributes |
|
Name |
|
|
character(len=*),
|
intent(in) |
|
|
:: |
string |
|
|
character(len=*),
|
intent(in) |
|
|
:: |
substring |
|
Return Value
logical
-
private elemental recursive function ends_with_cs(string, substring) result(res)
Arguments
| Type |
Intent | Optional | Attributes |
|
Name |
|
|
character(len=*),
|
intent(in) |
|
|
:: |
string |
|
|
type(String),
|
intent(in) |
|
|
:: |
substring |
|
Return Value
logical
-
private elemental recursive function ends_with_sc(string, substring) result(res)
Arguments
| Type |
Intent | Optional | Attributes |
|
Name |
|
|
type(String),
|
intent(in) |
|
|
:: |
string |
|
|
character(len=*),
|
intent(in) |
|
|
:: |
substring |
|
Return Value
logical
-
private elemental recursive function ends_with_ss(string, substring) result(res)
Arguments
| Type |
Intent | Optional | Attributes |
|
Name |
|
|
type(String),
|
intent(in) |
|
|
:: |
string |
|
|
type(String),
|
intent(in) |
|
|
:: |
substring |
|
Return Value
logical
The position where the occurrenceth occurrence (default 1) of pattern starts in string, or 0 if there is
none. Occurrences may overlap unless consider_overlapping is .false.. An empty pattern gives 0.
-
private elemental recursive function find_cc(string, pattern, occurrence, consider_overlapping) result(position)
Arguments
| Type |
Intent | Optional | Attributes |
|
Name |
|
|
character(len=*),
|
intent(in) |
|
|
:: |
string |
|
|
character(len=*),
|
intent(in) |
|
|
:: |
pattern |
|
|
integer,
|
intent(in), |
optional |
|
:: |
occurrence |
|
|
logical,
|
intent(in), |
optional |
|
:: |
consider_overlapping |
|
Return Value
integer
-
private elemental recursive function find_cs(string, pattern, occurrence, consider_overlapping) result(position)
Arguments
| Type |
Intent | Optional | Attributes |
|
Name |
|
|
character(len=*),
|
intent(in) |
|
|
:: |
string |
|
|
type(String),
|
intent(in) |
|
|
:: |
pattern |
|
|
integer,
|
intent(in), |
optional |
|
:: |
occurrence |
|
|
logical,
|
intent(in), |
optional |
|
:: |
consider_overlapping |
|
Return Value
integer
-
private elemental recursive function find_sc(string, pattern, occurrence, consider_overlapping) result(position)
Arguments
| Type |
Intent | Optional | Attributes |
|
Name |
|
|
type(String),
|
intent(in) |
|
|
:: |
string |
|
|
character(len=*),
|
intent(in) |
|
|
:: |
pattern |
|
|
integer,
|
intent(in), |
optional |
|
:: |
occurrence |
|
|
logical,
|
intent(in), |
optional |
|
:: |
consider_overlapping |
|
Return Value
integer
-
private elemental recursive function find_ss(string, pattern, occurrence, consider_overlapping) result(position)
Arguments
| Type |
Intent | Optional | Attributes |
|
Name |
|
|
type(String),
|
intent(in) |
|
|
:: |
string |
|
|
type(String),
|
intent(in) |
|
|
:: |
pattern |
|
|
integer,
|
intent(in), |
optional |
|
:: |
occurrence |
|
|
logical,
|
intent(in), |
optional |
|
:: |
consider_overlapping |
|
Return Value
integer
Removes every character in chars from both ends of string. For a String, chars is optional and defaults
to whitespace. trim(string) with one character argument is still the intrinsic trim.