|
NuMFor cf0f85d (2025-09-27)
Numerical (Modern) Fortran. Library for Simple Numerical computing
|
This module defines functions to manipulate strings of characters. Description. More...
Data Types | |
| interface | str |
str() converts a number (integer or real) to a string More... | |
Functions/Subroutines | |
| pure character(len=:) function, allocatable, public | upper (s) |
| Returns a copy of the string converted to uppercase. | |
| pure character(len=:) function, allocatable, public | lower (s) |
| Returns a copy of the string converted to lowercase. | |
| pure character(len=:) function, allocatable, public | swapcase (s) |
| Return str with case of letters swapped. | |
| pure character(len=:) function, allocatable, public | reverse (s) |
| Reverse a string. | |
| pure logical function, public | endswith (s, suffix) |
| Return True if S starts with the specified prefix, False otherwise. | |
| pure logical function, public | startswith (s, prefix) |
| Return True if S starts with the specified prefix, False otherwise. | |
| pure character(len=:) function, allocatable, public | lstrip (s, chars) |
| This function returns a copy of the string with leading chars removed. | |
| pure character(len=:) function, allocatable, public | rstrip (s, chars) |
| This function returns a copy of the string with trailing chars removed. | |
| pure character(len=:) function, allocatable, public | strip (s, chars) |
| This function returns a copy of the string with leading and trailing chars removed. | |
| pure integer function | count_sub (s, sub, start, end) |
| Return the number of occurrences of substring sub in string S[start:end]. | |
| pure logical function, public | issub (s, sub) |
| Returns .True. if sub is present in S, .False. otherwise. | |
| pure character(len=:) function, allocatable, public | rjust (s, width, fillchar) |
| Returns a right-justified string of length width. | |
| pure character(len=:) function, allocatable, public | ljust (s, width, fillchar) |
| Returns a left-justified string of length width. | |
| pure character(len=:) function, allocatable, public | zfill (s, width) |
| Pad a string with zeroes ("0") to specified width. If width is <= input string width, then the original string is returned. | |
| character(len=:) function, allocatable, public | center (s, width, fillchar) |
| Center a string to a specified width. The default character to fill in the centered string is a blank character. | |
| integer function, public | find (s, sub, start, end) |
| Return the lowest index in S where substring sub is found. | |
| character(len=:) function, allocatable, public | replace (s, old, new, count) |
| Return a copy with all occurrences of substring old replaced by new. | |
| integer function, public | str2i (s_in) |
| character(len=:) function, allocatable | z2str (zin) |
| z2str gives a string representation of a complex number | |
| function | zarr2str (vec) |
| function | dparr2str (vec) |
| function | rarr2str (vec) |
| function | iarr2str (vec) |
| character(len=:) function, allocatable | dparr2d2str (vec) |
| character(len=:) function, allocatable | rarr2d2str (vec) |
| character(len=:) function, allocatable | iarr2d2str (vec) |
| character(len=:) function, allocatable | zarr2d2str (vec) |
This module defines functions to manipulate strings of characters. Description.
| character(len=:) function, allocatable, public center | ( | character(len=*), intent(in) | s, |
| integer, intent(in) | width, | ||
| character(len=1), intent(in), optional | fillchar ) |
Center a string to a specified width. The default character to fill in the centered string is a blank character.
| [in] | s | Original string |
| [in] | width | Total width of centered string |
| [in] | fillchar | Padding character (default to space) |
| pure integer function count_sub | ( | character(len=*), intent(in) | s, |
| character(len=*), intent(in) | sub, | ||
| integer, intent(in), optional | start, | ||
| integer, intent(in), optional | end ) |
Return the number of occurrences of substring sub in string S[start:end].
| [in] | s | Original string |
| [in] | sub | substring to count |
| [in] | start | initial position to consider |
| [in] | end | final position to consider |
| character(len=:) function, allocatable dparr2d2str | ( | real(dp), dimension(:, :), intent(in) | vec | ) |
| [in] | vec | Vector of numbers to convert |
| function dparr2str | ( | real(dp), dimension(:), intent(in) | vec | ) |
| [in] | vec | Vector to convert |
| pure logical function, public endswith | ( | character(len=*), intent(in) | s, |
| character(len=*), intent(in) | suffix ) |
Return True if S starts with the specified prefix, False otherwise.
| [in] | s | Original string |
| [in] | suffix | substring to test |
S ends with sub. | integer function, public find | ( | character(len=*), intent(in) | s, |
| character(len=*), intent(in) | sub, | ||
| integer, intent(in), optional | start, | ||
| integer, intent(in), optional | end ) |
Return the lowest index in S where substring sub is found.
| [in] | s | original string |
| [in] | sub | substring to find |
| [in] | start | initial position to search |
| [in] | end | final position to search |
Referenced by str::dp2str(), and str::r2str().

| character(len=:) function, allocatable iarr2d2str | ( | integer, dimension(:, :), intent(in) | vec | ) |
| function iarr2str | ( | integer, dimension(:), intent(in) | vec | ) |
| [in] | vec | Vector to convert |
| pure logical function, public issub | ( | character(len=*), intent(in) | s, |
| character(len=*), intent(in) | sub ) |
Returns .True. if sub is present in S, .False. otherwise.
| [in] | s | Original string |
| [in] | sub | substring to find |
sub is present in S | pure character(len=:) function, allocatable, public ljust | ( | character(len=*), intent(in) | s, |
| integer, intent(in) | width, | ||
| character(len=1), intent(in), optional | fillchar ) |
Returns a left-justified string of length width.
| [in] | s | Original string |
| [in] | width | width of padded string |
| [in] | fillchar | Char used for filling |
| pure character(len=:) function, allocatable, public lower | ( | character(len=*), intent(in) | s | ) |
Returns a copy of the string converted to lowercase.
| [in] | s | Original string |
Referenced by str::dp2str(), and str::r2str().

| pure character(len=:) function, allocatable, public lstrip | ( | character(len=*), intent(in) | s, |
| character(len=*), intent(in), optional | chars ) |
This function returns a copy of the string with leading chars removed.
If chars is not present all blank: spaces (achar(32)) and tabs (achar(9)) are removed.
chars argument differs from intrinsic trim in that it will also strip "tab" characters | [in] | s | Original string |
| [in] | chars | chars to remove from S |
Referenced by str::dp2str(), str::r2str(), and strip().

| character(len=:) function, allocatable rarr2d2str | ( | real(sp), dimension(:, :), intent(in) | vec | ) |
| function rarr2str | ( | real(sp), dimension(:), intent(in) | vec | ) |
| [in] | vec | Vector to convert |
| character(len=:) function, allocatable, public replace | ( | character(len=*), intent(in) | s, |
| character(len=*), intent(in) | old, | ||
| character(len=*), intent(in) | new, | ||
| integer, intent(in), optional | count ) |
Return a copy with all occurrences of substring old replaced by new.
| [in] | s | original string |
| [in] | old | substring to replace |
| [in] | new | substring to substitute from old |
| [in] | count | Maximum number of occurrences to replace |
| pure character(len=:) function, allocatable, public reverse | ( | character(len=*), intent(in) | s | ) |
Reverse a string.
| [in] | s | Original string |
| pure character(len=:) function, allocatable, public rjust | ( | character(len=*), intent(in) | s, |
| integer, intent(in) | width, | ||
| character(len=1), intent(in), optional | fillchar ) |
Returns a right-justified string of length width.
| [in] | s | Original string |
| [in] | width | width of padded string |
| [in] | fillchar | Char used for filling |
| pure character(len=:) function, allocatable, public rstrip | ( | character(len=*), intent(in) | s, |
| character(len=*), intent(in), optional | chars ) |
This function returns a copy of the string with trailing chars removed.
If chars is not present all blank: spaces (achar(32)) and tabs (achar(9)) are removed.
chars argument differs from intrinsic trim in that it will also strip "tab" characters | [in] | s | Original string |
| [in] | chars | chars to remove from S |
Referenced by str::dp2str(), str::r2str(), and strip().

| pure logical function, public startswith | ( | character(len=*), intent(in) | s, |
| character(len=*), intent(in) | prefix ) |
Return True if S starts with the specified prefix, False otherwise.
| [in] | s | Original string |
| [in] | prefix | substring to test |
S starts with prefix Referenced by zfill().

| integer function, public str2i | ( | character(len=:), intent(in), allocatable | s_in | ) |
| [in] | s_in | String converted |
| pure character(len=:) function, allocatable, public strip | ( | character(len=*), intent(in) | s, |
| character(len=*), intent(in), optional | chars ) |
This function returns a copy of the string with leading and trailing chars removed.
If chars is not present all blank: spaces (achar(32)) and tabs (achar(9)) are removed.
chars argument differs from intrinsic trim in that it will also strip "tab" characters | [in] | s | Original string |
| [in] | chars | chars to remove from S |
References lstrip(), and rstrip().
Referenced by str::i2str(), and str::r2str().


| pure character(len=:) function, allocatable, public swapcase | ( | character(len=*), intent(in) | s | ) |
Return str with case of letters swapped.
| [in] | s | Original string |
| pure character(len=:) function, allocatable, public upper | ( | character(len=*), intent(in) | s | ) |
Returns a copy of the string converted to uppercase.
| [in] | s | Original string |
| character(len=:) function, allocatable z2str | ( | complex(dp), intent(in) | zin | ) |
z2str gives a string representation of a complex number
| character(len=:) function, allocatable zarr2d2str | ( | complex(dp), dimension(:, :), intent(in) | vec | ) |
| function zarr2str | ( | complex(dp), dimension(:), intent(in) | vec | ) |
| [in] | vec | Vector to convert |
| pure character(len=:) function, allocatable, public zfill | ( | character(len=*), intent(in) | s, |
| integer, intent(in) | width ) |
Pad a string with zeroes ("0") to specified width. If width is <= input string width, then the original string is returned.
| [in] | s | Original string |
| [in] | width | width of padded string |
References startswith().
