FindReplace
This routine finds the pattern inside the string, and replace it with the given pattern.
Interface
- ܀ Interface
- ️܀ See example
- ↢
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 substring pattern with a different substring in a string.
charsthe string which will have substrings replaced.findpthe substring pattern to find and replacereppthe new substring 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.
program main
use easifemBase
CHARACTER( LEN = 100 ) :: astr
astr = "Hello world, how are you"
CALL FindReplace(astr, "you", "you!")
CALL Display(astr, "astr = ")
end program main
Result
astr =Hello world, how are you!