I have a pattern which looks like:
abc*_def(##)
and i want to look if this matches for some strings. E.x. it matches for:
abc1_def23
abc10_def99
but does not match for:
abc9_def9
So the * stands for a number which can have one or more digits. The # stands for a number with one digit I want the value in the parenthesis as result
What would be the easiest and simplest solution for this problem? Replace the * and # through regex expression and then look if they match? Like this:
pattern = pattern.replace('*', '[0-9]*')
pattern = pattern.replace('#', '[0-9]')
pattern = '^' + pattern + '$'
Or program it myself?