Question by
cavalierkc · Oct 21, 2016 at 12:34 PM ·
c#regex
How do i make my regex return something if NULL
I have a regex query which if it doesn't always find anything VS throws out an error because of this so how do I get my code to set a string called GoingToString to "NO DATA" for example and continue with the rest of the code?
var GetGoing = new Regex(@"(?<=<li><B>Going:</B> )(.*?)(?=<li><B>)").Matches(set);
foreach (var Going in GetGoing)
{
// convert var to string
string GoingToString = Going.ToString();
// write GoingToString to the file
File.AppendAllText(StringFileDat, " " + GoingToString + " ");
if (DebugChechBox.Checked == true)
{
Console.WriteLine("Going is " + Going);
GoingBox.Text = GoingToString;
}
Comment
Your answer
Follow this Question
Related Questions
Pass values as bool or number type using SimpleJSON 0 Answers
I'm trying to make the collision work. But... 2 Answers
Rotation towards raycast hit point, 1 Answer
Radius too long 1 Answer