Hi All,
I am loading in data putting it in a string variable and the going through it with a
char[] delimetersChars = { '\n', '\r'};
and a string[] Values = FileData.Split(delimetersChars);
The delimetersChars had the < & > chars as I am using those to denote the start & end of messages. In the act of spotting possible errors as the data is not always reliable...
if (!Values[a].Contains('<') || !Values[a].Contains('>'))
Values[a] = "";
My thinking was this would check to see if there is an < & > is there an easier (better) way to do this.
Glenn
Loading
VulpesPosted Mar 13, 2012, 12:56 PM
The output in the RTB should be:
abc
def
ghi
jkl
Glenn PattonPosted Mar 14, 2012, 6:55 AM
VulpesPosted Mar 14, 2012, 6:52 AM
Here's a couple of good articles on regular expressions:
http://www.codeproject.com/Articles/9099/The-30-Minute-Regex-Tutorial
http://www.c-sharpcorner.com/UploadFile/Kolonist/regularexpressions07042006083534AM/regularexpressions.aspx
Glenn PattonPosted Mar 14, 2012, 5:11 AM
instead of string regExp = @"(?<=<).+?(?=>)";
Know of a good source for RegEx for the unknowing
Thanks Glenn
Glenn PattonPosted Mar 14, 2012, 4:52 AM
<123456789987654321><987654321987654321>
I suppose I should have mention it earlier!
Glenn
VulpesPosted Mar 13, 2012, 1:21 PM
Is that not what's wanted?
Glenn PattonPosted Mar 13, 2012, 1:17 PM
VulpesPosted Mar 13, 2012, 1:10 PM
Glenn PattonPosted Mar 13, 2012, 1:02 PM
The code I have is below but from the debugger I am not going in the the if,
any ideas?
Glenn PattonPosted Mar 13, 2012, 12:44 PM
Glenn PattonPosted Mar 13, 2012, 12:44 PM
VulpesPosted Mar 13, 2012, 12:23 PM
Glenn PattonPosted Mar 13, 2012, 8:16 AM
I am trying now
the delimeterCharFurther is a character array of < >, the below code appears to take out the < & > and blanks but includes data the does not have the enclosing < >
Glenn
VulpesPosted Mar 13, 2012, 6:08 AM
// do some processing
Glenn PattonPosted Mar 13, 2012, 5:13 AM
I need it to restart the if()
Glenn PattonPosted Mar 12, 2012, 11:45 AM
VulpesPosted Mar 12, 2012, 11:37 AM
Glenn PattonPosted Mar 12, 2012, 11:30 AM
Glenn PattonPosted Mar 12, 2012, 11:30 AM
VulpesPosted Mar 12, 2012, 11:27 AM
However, if there was any possibility that values[a] could be null (not the same as empty), you'd need to put a check in for that.
Glenn PattonPosted Mar 12, 2012, 10:54 AM
May have solved this my self what is the learned view of the below:
if ((String.Empty != Values[a]) && ((Values[a].StartsWith("<") && Values[a].EndsWith(">"))))
MessageBox.Show(Values[a].Replace("<", "").Replace(">", ""));
seems to work? but is it to standard?
Glenn