Geeks With Blogs

News My Blog has been MOVED to
Michael Freidgeim's OLD Blog My Blog has been MOVED to
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

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

Find what
replace with

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: