How to replace instances of a word in a string while using Streams

Hello everyone! Help me guys i come from C language programming so on first time my brain exloded.
I ha ve simple target. I have a dump file (its utf8 file) in which i must replace all word “” to “”. How to do it?
I wrote this code

defmodule Filereader do
	def parse do!("dump")
	def perfomandwrite(a) do
			b=Elixir.String.replace(a, "", "")
			{:ok, file} "out", [ :append]
			IO.write file,b
			File.close file

Its compiled but not work. What i doing wrong?

1 Like

You aren’t executing anything. :slight_smile:

Try adding Filereader.parse() to the end of the file, saving the file as foo.exs, and then running elixir foo.exs.


Keep in mind that only returns :ok, so a isn’t going to be what you think it is. You may want to make sure you run through one of the Elixir books.

1 Like