Pythonic string.replace() in Nim?

Viewed 366

How to replace some string with Nim ?

var pythonista:string = "Power of Python!"
echo pythonista
1 Answers

First, you need to import strutils module. Strutils is the module that defines several common functions for working with strings.

So the code will be like this:

import std/strutils
    
var pythonista:string = "Power of Python!"
echo pythonista
echo "============"
echo pythonista.replace("Python!", "Nim :)")
echo "============"
Related