Function that removes the characters of a string from another string
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | string |
string to be modified |
||
character(len=*), | intent(in) | :: | chars |
list of characters to remove |
returned string
function str_remove_chars(string, chars) !! Function that removes the characters of a string from another string implicit none character(len = :), allocatable :: str_remove_chars !! returned string character(len = *), intent(in) :: string !! string to be modified character(len = *), intent(in) :: chars !! list of characters to remove integer(kind = I4) :: i, j str_remove_chars = '' ! Loop through each character in the input string j = 1 do i = 1, len_trim(string) if ( index( chars, string(i:i) ) == 0 ) then str_remove_chars = str_remove_chars // String(i:i) j = j + 1 endif enddo return endfunction str_remove_chars