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 |
pure function replace(string, charset, target_char) result(res) character(*), intent(in) :: string character, intent(in) :: charset(:), target_char character(len(string)) :: res integer :: n res = string do n = 1, len(string) if (any(string(n:n) == charset)) then res(n:n) = target_char end if end do end function replace