c# - I would like to make a pattern using regex -


i make regex pattern ,i make pattern value inside brackets ,i tried 1 not working.

string input = "(3+4)+5*4"; match m = regex.match(input, @"([(0-9\/\+\-\*0-9)])"); if (m.success) {     string value = m.groups[1].tostring();     messagebox.show(value); } 

what doing mis-understanding "class" in regular expression.

[] - denotes set of characters match.  not pattern. 

what need grabbing pattern, did have correct.

(\([0-9][\/\+\-\*][0-9]\))  capture:   open parenthesis   character in [0-9]   character in [\/\+\*\-]   character in [0-9]   close parenthesis 

this allow 1 digit though. if have multi digit number, 10...this wont work. now, if changed this:

(\([0-9]+[\/\+\-\*][0-9]+\)) 

those + tell regex capture one or more. allow number, not single digit.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -