here you go Stefan_Salewski import strutils proc transform(str: string): string = const matcher = "Array" for (elem, isSep) in str.tokenize(Whitespace + {',', ';'}): if elem.endsWith(matcher): result.add "ptr " & elem[0 .. ^(matcher.len + 1)] else: result.add elem when isMainModule: import unittest suite "t6775": test "transform": block: let raw = "(self: ptr GApplication00; files: GFile00Array; nFiles: int32; hint: cstring; user_data: pointer)" let trans = "(self: ptr GApplication00; files: ptr GFile00; nFiles: int32; hint: cstring; user_data: pointer)" check raw.transform() == trans block: let raw = "(self: ptr GApplication00, files: GFile00Array, nFiles: int32, hint: cstring, user_data: pointer)" let trans = "(self: ptr GApplication00, files: ptr GFile00, nFiles: int32, hint: cstring, user_data: pointer)" check raw.transform() == trans Run