Regex.....Problem...........
-
string sPattern = @"[^\p{Cc}\\r\\n\\a\\e\\b\\t][\S]*[\w\p{Po}\s-`\p{Sm}]*[^\p{Cc}\\r\\n\\a\\e\\b\\t]"; try { if (Regex.IsMatch(txtText.Text, sPattern, RegexOptions.Multiline | RegexOptions.IgnoreCase)) { objMatch = Regex.Match(txtText.Text, sPattern, RegexOptions.ECMAScript | RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnoreCase); if (objMatch.Success) lblDone.Text = objMatch.Value; }//end (if (Regex.IsMatch...) }//end(try) finally { sPattern = null; }//end (finally) input string is :-- \r\nloadplayer "playername=test_1"\r\n output string should be :-- loadplayer "playername=test_1" want to neglect all newline,tabs.. etc from the input string. Now its doing fine, but also removing "r,n,a,e,b,t" from the starting of the input string. Means, if the input string is:-- roadplayer "playername=test_1"\r\n output becomes:-- oadplayer "playername=test_1" it should be:-- roadplayer "playername=test_1" so, tell me what i should do for better working. Thxx... Enjoy!!
-
string sPattern = @"[^\p{Cc}\\r\\n\\a\\e\\b\\t][\S]*[\w\p{Po}\s-`\p{Sm}]*[^\p{Cc}\\r\\n\\a\\e\\b\\t]"; try { if (Regex.IsMatch(txtText.Text, sPattern, RegexOptions.Multiline | RegexOptions.IgnoreCase)) { objMatch = Regex.Match(txtText.Text, sPattern, RegexOptions.ECMAScript | RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnoreCase); if (objMatch.Success) lblDone.Text = objMatch.Value; }//end (if (Regex.IsMatch...) }//end(try) finally { sPattern = null; }//end (finally) input string is :-- \r\nloadplayer "playername=test_1"\r\n output string should be :-- loadplayer "playername=test_1" want to neglect all newline,tabs.. etc from the input string. Now its doing fine, but also removing "r,n,a,e,b,t" from the starting of the input string. Means, if the input string is:-- roadplayer "playername=test_1"\r\n output becomes:-- oadplayer "playername=test_1" it should be:-- roadplayer "playername=test_1" so, tell me what i should do for better working. Thxx... Enjoy!!
The 'escape characters' are all in the format '\x'. \n is new line... etc. '\\' in a string represents a '\', a single '\' will look like an escape character. So you need to use: \n \r etc instead of \\n \\r. I've never use Regex before but I assume this is right. Hope it helps.
Matthew Butler