I’m trying to find a String in a Textfile. I’m using the RegEx Method for that. But I need to get the Previous String, which is existing before the found String, as Method Output. How can i do it with c#? Can anyone give me some Idea?
For Example:
In that Textfile is a Line with 'routerbl router0000;'
I’m searching 'router0000;' and if i find 'router0000;' then i want to get 'routerbl'.
You have two possibilities
Match what you want using a capturing group, something like this
and you will find your result in the capturing group 1
Match your pattern and ensure the following string with a lookahead
this will match only the part you want.