c# - I need Regex and to find the occurrence of "Processing" keyword and print the following text if the first word is Processing -


string s = textbox1.text; string[] lines = s.split(environment.newline.tochararray());  foreach (string l in lines) {     if (regex.ismatch(lines.(here when select .tostring() no o/p), pattern))     {         textbox3.text = textbox3.text + l + environment.newline+;     } } 

for example if input is:

processing \\users\\bhargava\\desktop\new.txt processing \\users\\bhargava\\desktop\\new2.txt <get process id> processing \\users\\bhargava\\desktop\new3.txt <get element id> processing \\users\\bhargava\\desktop\\new4.txt 

output is:

processing \\users\\bhargava\\desktop\new.txt processing \\users\\bhargava\\desktop\\new2.txt  processing \\users\\bhargava\\desktop\new3.txt  processing \\users\\bhargava\\desktop\\new4.txt 

you don't need regex this.

http://msdn.microsoft.com/en-us/library/k8b1470s.aspx

string.indexof(string) reports zero-based index of first occurrence of specified string in instance. returns -1 if string not occur in instance.

e.g.

if (l.indexof("processing") == 0) {     //do stuff } 

(for reference though, regex processing)


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -