str_remove_chars Function

public function str_remove_chars(string, chars)

Function that removes the characters of a string from another string

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: string

string to be modified

character(len=*), intent(in) :: chars

list of characters to remove

Return Value character(len=:), allocatable

returned string


Called by

proc~~str_remove_chars~~CalledByGraph proc~str_remove_chars str_remove_chars program~test_files test_files program~test_files->proc~str_remove_chars

Source Code

   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