See updated code above using fancier pattern.
(Why do you think think the original would not work for alpha?) | [reply] |
Yes, the improved code is fine, and covers all cases.
However, the goal is to have code which is fine and covers all cases AND IS SIMPLER. I want simple because I need to recommend this to testers who don't know necessarily know what a regular expression is. I can tell them to stick in a \b at the beginning and end of each word to be matched, and I can even explain it to them. Unfortunately, \b doesn't always work.
The more complicated expressions such as you used (and I suggested) are not so easy to recommend or explain. I just want to know if there is some simple way to do what seems like a simple task.
| [reply] |
I, for one, always prefer "simple" (or "simpler"). But, it seems to me, that "simpler" is not always compatible with the demands of the situation. It seems to me (not that I'm by any means really qualified to make this assertion) that the situation you're addressing is, by its nature, not easily handled by anything "simple". In my experience this is espeically true (or perhaps I should say "tends to be true"...I guess it depends upon one's familiarity and accumen with regexs) when regexs are involved. I think the strategy that gmargo proposed is elegantly "simple" in terms of regexs and I, like gmargo, am not sure why it wouldn't work for cases other than just for 'beta'. At the end of the day, I guess I don't know what you're imagining is "simple" or "simpler". But that's probably just my misunderstanding of what you're looking for.
| [reply] |