Menu

Problem parsing string arguments

Help
2005-12-08
2013-03-22
  • Eduardo Zacarías B.

    Hello!

    I have been using xParam to parse input arguments to my programs with no problems, but I ran into the following issue while parsing a given string:

    The NoViableAlt exception is thrown when the string argument contains the character "+"

    e.g.

    myProgram theString="onlyAlphaNumeric"

    goes well, but

    myProgram theString="onlyAlphaNumeric+someMore"

    fails.

    Wondering what's the problem. I thought that the parser would copy the chars from argv if it realizes that is not a number.

    Thanks a lot!

    Eduardo

     
    • Ronnie Maor

      Ronnie Maor - 2005-12-17

      the shell strips your quotes, so what XParam gets as input is
      onlyAlphaNumeric+someMore

      which is not a valid string in XParam. You need to give XParam this:
      "onlyAlphaNumeric+someMore"

      one common way to do this is give this input at the shell:
      myProgram 'theString="onlyAlphaNumeric+someMore"'
      (added single quotes around all input)

       

Log in to post a comment.

MongoDB Logo MongoDB