Note that there are some explanatory texts on larger screens.

plurals
  1. POExtracting one word based on special character using Regular Expression in C#
    text
    copied!<p>I am not very good at regular expression but want to do some thing like this :</p> <p>string="c test123 d split"</p> <p>I want to split the word based on "c" and "d". this can be any word which i already have. The string will be given by the user. i want "test123" and "split" as my output. and there can be any number of words i.e "c test123 d split e new" etc. c d e i have already with me. I want just the next word after that word i.e after c i have test123 and after d i have split and after e i have new so i need test123 and split and new. how can I do this??? And one more thing <strong>I will pass just c first than d and than e. not together all of them. I tried</strong> </p> <blockquote> <p>string strSearchWord="c ";<br> Regex testRegex1 = new Regex(strSearchWord); List lstValues = testRegex1.Split("c test123 d split").ToList();</p> </blockquote> <p>But it's working only for last character i.e for d it's giving the last word but for c it includes test123 d split.</p> <p>How shall I do this???</p> <p>The input might be </p> <p>string strSearchWord="c mytest1 d newtest1 e lasttest1"; split should be based on characters "c d and e". I will pass them one by one.</p> <p>or</p> <p>string strSearchword="q 100 p 200 t 2000"; split should be based on characters "q p and t". I will pass them one by one.</p> <p>or string strSearchWord="t 100 r pass"; split should be based on characters "t r". I will pass them one by one.</p> <p>or</p> <p>string strSeaRCHwORD="fi 100 se 2000 td 500 ft 200 fv 6000 lt thanks "; split should be based on characters "fi,se,td,ft,fv and lt". I will pass them one by one.</p> <p>Hope it's clear. Any other specification????</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload