regex - Convert string containing wildcards to regexp -
i need convert string containing wildcards regexp.
for example, if have input string below:
ab*dd*c
this means
ab(any number of characters)d(any number of characters)c
where any character
alphanumeric character or '_'.
i've tried below:
'ab([[:alnum]] | '_')*dd([[:alnum]] | '_')*c'
but, can see, for, example, ([[:alnum]] | '\_')*
matches d
also, and, so, couldn't needed match.
what comes mind use below:
'ab[^ d]*dd[^ c]*c'
is there better solution?
thanks in advance!
you can use regex:
/ab\w*?dd\w*?c/
\w*?
match alphanumeric character or _ non-greedy.
Comments
Post a Comment