Home All Groups Group Topic Archive Search About

Parsing strings to objects (techniques)

Author
13 Apr 2005 10:58 PM
Cesar Ronchese
Hi All.

I need to parse a command-line string and transform results in some objects.
For sample:

myapp.exe /param1="textwith""quotes" /param2=other text /param3=123
   ...will become:
objParam("param1").Value = "textwith""quotes"
objParam("param2").Value = "other text"
objParam("param3").Value = "123"

Note the double quotes in the text. I need to recognize that as a simple
quote, like SQL do.

What I really need is about techniques or a specific class for do that work,
because that string can be huge and very complicated, according the context.

Any suggestion?

Cesar

Author
14 Apr 2005 8:51 AM
Larry Lard
Cesar Ronchese wrote:
Show quoteHide quote
> Hi All.
>
> I need to parse a command-line string and transform results in some
objects.
> For sample:
>
> myapp.exe /param1="textwith""quotes" /param2=other text /param3=123
>    ...will become:
> objParam("param1").Value = "textwith""quotes"
> objParam("param2").Value = "other text"
> objParam("param3").Value = "123"
>
> Note the double quotes in the text. I need to recognize that as a
simple
> quote, like SQL do.
>
> What I really need is about techniques or a specific class for do
that work,
> because that string can be huge and very complicated, according the
context.

Read up in the MSDN on Regular Expressions (all the stuff in the
namespace System.Text.RegularExpressions). Feel free to come back with
more specific questions :)

--
Larry Lard
Replies to group please