CASL / Futility

VERA Fortran Utilities
Other
44 stars 20 forks source link

Implements string replace method and testing #216

Closed HendersonSC closed 4 years ago

HendersonSC commented 4 years ago

Implements %replace() method as a generic. One implementation takes a starting index and optionally a stopping index replacing everything in between with repetitions of a supplied character pattern. The other replaces all occurrences of a specified pattern with a replacement pattern.

To do this it became advantageous to implement %split() generically as well. The first implementation, without arguments uses a single space as the delimiter and consumes consecutive delimiters returning an array of strings containing no empty strings. The other implementation utilizes a user supplied delimiter. This does not consume consecutive delimiters and instead returns a string array which may contain empty strings where consecutive delimiters occurred. If the delimiter is not found then both implementations will return a size 1 array containing the original string.

This aimed to be a functional mirror of the python method by the same name.

aarograh commented 4 years ago

I'm good with the current set of changes. Downstream codes will need some minor updates before deleting strrep. I'll make an issue to do so once those codes are updated.

@stimpsonsg Can you merge?