MPAS-Dev / MPAS-Model

Repository for MPAS models and shared framework releases.
238 stars 317 forks source link

Add mpas_string_replace to mpas_string_utils #1110

Closed dimomatt closed 1 year ago

dimomatt commented 1 year ago

Add mpas_string_replace to replace characters in a given string.

A function to replace characters in a string with another character has been added to the mpas_string_utils module, along with tests in mpas_test_core. The function searches for a character (charToReplace) inside of an input string, and replaces any instances of that character with another character (targetCharacter). Strings are trimmed before characters are replaced to avoid potential issues with trailing whitespace when replacing spaces.

Tests include consecutive characters, whitespace characters, and attempting to replace a character that does not appear in the input string.