1

I wrote a program to convert a xml file. I started it with the following command

ruby Skribt.rb example

Here is a part of the code:

sessionid = ARGV[0].dup
inputfile = "upload/" + sessionid + "_source.xml" # Hochgeladene XML Datei
outputfile = "output/" + sessionid + ".xml"
stringKomplett = File.read(inputfile,encoding: "UTF-8").gsub(/<group.*?type=\"public\".*?\/>/, "")

I get the following error and do not know how to solve this.

Skript.rb:16: syntax error, unexpected ':', expecting ')'
... File.read(inputfile,encoding: "UTF-8").gsub(/<group.*?type=...
                              ^
Skript.rb:16: syntax error, unexpected ')', expecting $end
...d(inputfile,encoding: "UTF-8").gsub(/<group.*?type=\"public\...
                          ^

I hope you can help me with this problem. Thank you in advance for you help.

Greetings

1
  • 1
    what ruby version you are using? Commented Mar 12, 2015 at 10:24

1 Answer 1

2

It seems you are using older Ruby version. Try this instead:

File.read(inputfile, :encoding => "UTF-8").gsub(/<group.*?type=\"public\".*?\/>/, "")
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you very much. It is a bit strange, that apt-get says, that I have the newest version of ruby and at the same time ruby -v says I have 1.87. But now it does its task, so everything ok :)
@Firevulture thats great. Please accept the answer if it solved your problem :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.