Well it's late, and I'm way too inexperienced with perl/regex to figure this out on my own...
I'm writing a perl script to accept input (commands) from the user. I want to implement a 'closest match' type scheme on accepting the input.
- A valid command is 'update' and 'upload'
- The user should be able to type 'upd' or 'update' etc to execute the 'update' command. 'upte' is not valid.
- The user should be able to type 'upl' or 'uplo' etc to execute the 'upload' command. upod is not valid.
- The command 'up' can't be matched to a unique command.
I'm using the following regex at the moment:
This works EXCEPT for treating 'upte' and 'upod' as matches.
I think I need a way in the regex similar to ? except to say "match the preceding character or nothing, and stop looking
" rather than "match the preceding character, or don't
Any ideas folks?