Regular expression to recognize truncated search string forms?
I am trying to formulate a regex that recognizes a search term truncated by any number of characters on the right.
For example, if the search term is "pickle", the regular expression must recognize "pi", "pick", but not "pickaxe".
I originally came up with the following:
p(i(c(k(l(e)?)?)?)?)?
This works great, but it seems like a crude way to do it. Is there a better way to do this? I was looking for something similar to what I want, but I'm not really sure what to look for.
+2
a source to share