c# - Look for words in a textbox text and display in data grid -


i need program windows form in c#, needs textbox , button. in textbox have type programming instruction example: for(i=0;i<10;i++)

then click button , in datagrid should displayed this:

  1. for - cycle
  2. ( - agrupation
  3. i - variable
  4. = - asignation

    and on

how can identify parts of text?

i've tried foreach char i'm messed :( please

here solution can use cobbled together. highly recommend familiarise regular expressions:

https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx

and here nice tester used: http://regexstorm.net/tester

using system.text.regularexpressions;   string input = "for(i=0;i<10;i++)";         string pattern = @"^(\w+)(\w)(\w)(\w).*$";         matchcollection matches = regex.matches(input, pattern);          string cycle = matches[0].groups[1].value;         string agrupation = matches[0].groups[2].value;         string variable = matches[0].groups[3].value;         string asignation = matches[0].groups[4].value;          string test = string.format("cycle: {0}, agrupation: {1}, variable={2}, asignation: {3}", cycle, agrupation, variable, asignation);          console.writeline(test); 

Comments

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

laravel - Undefined property: Illuminate\Pagination\LengthAwarePaginator::$id (View: F:\project\resources\views\admin\carousels\index.blade.php) -