regular expression

P

puzzlecracker

Guys,

I am starting to use regular expressions in csharp. Would someone
explain the following code snippet, as to how it actually parses
things ?

Regex Spliter = new Regex(@"^-{1,2}|^/|=|:",
RegexOptions.IgnoreCase|RegexOptions.Compiled);

Regex Remover = new Regex(@"^['""]?(.*?)['""]?$",
RegexOptions.IgnoreCase|RegexOptions.Compiled);


Thanks
 
A

Arne Vajhøj

puzzlecracker said:
I am starting to use regular expressions in csharp. Would someone
explain the following code snippet, as to how it actually parses
things ?

Regex Spliter = new Regex(@"^-{1,2}|^/|=|:",
RegexOptions.IgnoreCase|RegexOptions.Compiled);

line start
1 or 2 dashes or hat slash or equals or colon
Regex Remover = new Regex(@"^['""]?(.*?)['""]?$",
RegexOptions.IgnoreCase|RegexOptions.Compiled);

line start
single or double quote or nothing
anything but not greedy so will stop at first match of the following
single or double quote or nothing
line end

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top