regex - .net search for string between two known strings in a file -


i have big text file. lots of irrelevant data in it. can read streamreader , doing while loop. text file this

mystartstring "response:"my response web service1 myendstring somedata in between ***mystartstring* "response:"my response web service2 **myendstring

so going (around 70mb file). need retrieve "response:"my response web service1 , "response:"my response web service2 etc list. saw can regex. can me out. saw stackoverflow post on this.

update: pasting below file extract. so, can see "****mgrtype response body**" , "**end::" below. there response between them. need responses. image fileregex correct matched 2 matches

my file extract :

employeetype: manager

mgrtype request payload {"events":[{"some data"}]}}}}]}

****nfn response header**

x-original-http-status-code: 200

myid: cc24e044-babf-46d3-bda5-bb0de1e586e5

connection: close

date: tue, 14 jun 2016 21:28:01 gmt

*mgrtype response body

{"response":{" data 1 \n--- end messages ---\n"}]}}}

end::event 1 out of 1

* done nfn xyzserver*

somedata here1

somedata here2

somedata here3

somedata here4

...

somedata here555

*mgrtype response body

{"response":{" data 2\n--- end messages ---\n"}]}}}

end::event 1 out of 1

* done nfn xyzserver*

use regex.match , in pattern search character between start , end strings.if match,add list.

string s; list<string> slist = new list<string>();  using(streamreader oreader = new streamreader("text1.text")) {      while((s = oreader.readline()) != null)      {          slist.add(regex.match(s, @"mystartstring(.+?)myendstring").groups[1].value);      } } foreach(string s in slist)     console.writeline(s); 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -