c# - split string in substring using a string delimiter -


i've string message like

"trx00  abcd 20150921    "  

or (n) times string, i.e.

"trx00  abcd 20150921    trx00  abcd 20150921    trx00  abcd 20150921    "  

etc..

how can split string in (n) strings using "trx" @ beginning of each substring delimiter?

i want take delimiter "trx" in substring.

i've done following it's doesn't work well..

string msg = "trx00  abcd 20150921    trx00  abcd 20150921    trx00  abcd 20150921    ";  string[] _msg; string pattern = "(trx)"; string msg2 = "";  if(msg.contains("trx")) {     _msg = regex.split(msg, pattern);      foreach (string ok in _msg)     {         msg2 = ok;         messagebox.show(msg2);     } } 

the expected result should array of substrings like:

{ "trx00 abcd 20150921 ", "trx00 abcd 20150921 ", etc.. }  

you can use pattern in code instead of (trx):

(?!^)(?=trx) 

it split on trx long isn't @ start of string , returns:

trx00 abcd 20150921

trx00 abcd 20150921

trx00 abcd 20150921


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -