Geeks With Blogs

News My Blog has been moved to https://mfreidge.wordpress.com
Michael Freidgeim's Blog My Blog has been moved to https://mfreidge.wordpress.com
I’ve received a .csv report from TripWire logs, where each entry is a long text strings.
I needed to extract some substring from each row, e.g “ErrorCode: ABC1234” where preceding text is constant, but actual error code could be different.
In TSQL I can do someting similar using patIndex and substring, e.g.
select text,substring(TEXT,PATINDEX ('%ErrorCode:%',TEXT),10)

In C# I can do it using RightAfter and TrimLength from My StringHelper
RightAfter(Text,”ErrorCode:”).TrimLength(10)  

But I was able to do it In Visual Studio Editor using replace and tick ‘Use regular expressions”

Find what
^.*ErrorCode:
replace with
ErrorCode:

I would appreciate suggestions to do similar extracts using other tools.

Related post

Remove empty lines in text using Visual Studio.

Posted on Sunday, March 11, 2012 1:59 PM Testing/Debugging/Logging , Visual Studio/TFS/git | Back to top


Comments on this post: Extract substrings starting with known text from long lines

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net