R
Richard L Rosenheim
I have some text where I need to extract some pieces from. The text will be
in a format like this:
a string description color="red" type="unknown"
In the above example, I would be looking to extract the word "red".
There's couple of ways I could approach the problem. I could use IndexOf to
search for the string 'color=' and then extract the value using the Substr
method. Or, I could use a regular expression like:
color="([a-z]|[A-Z])+"
In this case, the Match method would return the string 'color="red"'. I
could then use the Substr method to extract the string 'red'. Of course,
using a regular expression might be a little overkill in this case.
I'm just wondering if there is, buried in the 1500+ classes of .NET, a
better approach. Or, if there is a way of getting a regular expression to
return just the string within the quotes.
Richard
in a format like this:
a string description color="red" type="unknown"
In the above example, I would be looking to extract the word "red".
There's couple of ways I could approach the problem. I could use IndexOf to
search for the string 'color=' and then extract the value using the Substr
method. Or, I could use a regular expression like:
color="([a-z]|[A-Z])+"
In this case, the Match method would return the string 'color="red"'. I
could then use the Substr method to extract the string 'red'. Of course,
using a regular expression might be a little overkill in this case.
I'm just wondering if there is, buried in the 1500+ classes of .NET, a
better approach. Or, if there is a way of getting a regular expression to
return just the string within the quotes.
Richard