GivenRandy
asked on
RegEx - More Requirements
Releated to earlier question(s):
https://www.experts-exchange.com/questions/22034295/RegEx-Remove-Trailing-Spaces-on-Line.html
Starting fresh, with some additional requirements. There are a bunch of lines, ending with with "\r\n", that are in a long string. The replacement string needs to:
+ remove "//" and anything after it (could also see just "//\r\n", with no text on line after the "//")
+ remove tab ("\t") characters
+ remove blank lines (either with OR without whitespace before the "\r\n")
+ remove leading whitespace at beginning of line
+ remove trailing whitespace at end of line
https://www.experts-exchange.com/questions/22034295/RegEx-Remove-Trailing-Spaces-on-Line.html
Starting fresh, with some additional requirements. There are a bunch of lines, ending with with "\r\n", that are in a long string. The replacement string needs to:
+ remove "//" and anything after it (could also see just "//\r\n", with no text on line after the "//")
+ remove tab ("\t") characters
+ remove blank lines (either with OR without whitespace before the "\r\n")
+ remove leading whitespace at beginning of line
+ remove trailing whitespace at end of line
ASKER
Right, all of the \t in the whole string. Just delete them.
Right now, I have like 5 lines of code to do this and trying to reduce to one. Not just for analysis-paralysis, but to help learn RegEx in the background. :)
Right now, I have like 5 lines of code to do this and trying to reduce to one. Not just for analysis-paralysis, but to help learn RegEx in the background. :)
You do not need to replace \t with any other character?
ASKER
Correct. It gets stripped. It was a carryover from a tab-delimited file, but the tabs are not significant -- it now is space separated and newlines.
ASKER
Something like this at the moment:
cleanedText = Regex.Replace(cleanedText, "[\t]", String.Empty)
I used the brackets because there had been other characters in the set as well. Now, just the tab.
cleanedText = Regex.Replace(cleanedText,
I used the brackets because there had been other characters in the set as well. Now, just the tab.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Touche!
Glad I was able to help. ;=)
Whe you say, "remove tab ("\t") characters", That is all \t in the string data?
Fernando