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

VulpesRank #55 · 29.2K reputationPosted Mar 13, 2012, 8:56 AM EDT
The output in the RTB should be:
abc
def
ghi
jkl
Glenn PattonRank #6,159 · 275 reputationPosted Mar 12, 2012, 6:54 AM EDT
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
VulpesRank #55 · 29.2K reputationPosted Mar 12, 2012, 7:27 AM EDT
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 PattonRank #6,159 · 275 reputationPosted Mar 12, 2012, 7:30 AM EDT
Glenn PattonRank #6,159 · 275 reputationPosted Mar 12, 2012, 7:30 AM EDT
VulpesRank #55 · 29.2K reputationPosted Mar 12, 2012, 7:37 AM EDT
Glenn PattonRank #6,159 · 275 reputationPosted Mar 12, 2012, 7:45 AM EDT
Glenn PattonRank #6,159 · 275 reputationPosted Mar 13, 2012, 1:13 AM EDT
I need it to restart the if()
VulpesRank #55 · 29.2K reputationPosted Mar 13, 2012, 2:08 AM EDT
// do some processing
Glenn PattonRank #6,159 · 275 reputationPosted Mar 13, 2012, 4:16 AM EDT
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
VulpesRank #55 · 29.2K reputationPosted Mar 13, 2012, 8:23 AM EDT
Glenn PattonRank #6,159 · 275 reputationPosted Mar 13, 2012, 8:44 AM EDT
Glenn PattonRank #6,159 · 275 reputationPosted Mar 13, 2012, 8:44 AM EDT
Glenn PattonRank #6,159 · 275 reputationPosted Mar 13, 2012, 9:02 AM EDT
The code I have is below but from the debugger I am not going in the the if,
any ideas?
VulpesRank #55 · 29.2K reputationPosted Mar 13, 2012, 9:10 AM EDT
Glenn PattonRank #6,159 · 275 reputationPosted Mar 13, 2012, 9:17 AM EDT
VulpesRank #55 · 29.2K reputationPosted Mar 13, 2012, 9:21 AM EDT
Is that not what's wanted?
Glenn PattonRank #6,159 · 275 reputationPosted Mar 14, 2012, 12:52 AM EDT
<123456789987654321><987654321987654321>
I suppose I should have mention it earlier!
Glenn
Glenn PattonRank #6,159 · 275 reputationPosted Mar 14, 2012, 1:11 AM EDT
instead of string regExp = @"(?<=<).+?(?=>)";
Know of a good source for RegEx for the unknowing
Thanks Glenn
VulpesRank #55 · 29.2K reputationPosted Mar 14, 2012, 2:52 AM EDT
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 PattonRank #6,159 · 275 reputationPosted Mar 14, 2012, 2:55 AM EDT