Skip to main content

FindReplace

This routine finds the pattern inside the string, and replace it with the given pattern.

Interface

 INTERFACE
MODULE PURE SUBROUTINE FindReplace(chars, findp, repp)
CHARACTER(*), INTENT(INOUT) :: chars
CHARACTER(*), INTENT(IN) :: findp
CHARACTER(*), INTENT(IN) :: repp
END SUBROUTINE FindReplace
END INTERFACE

Replaces a sub-string pattern with a different sub-string in a string.

  • chars the string which will have sub-strings replaced.
  • findp the sub-string pattern to find and replace
  • repp the new sub-string that will replace parts of string

repp can be larger than findp and as long as the size of string can accomodate the increased length of all replacements. Trailing and preceding spaces are counted in all strings.