Re: regex
Originally Posted by
finer recliner
is there a way in grep to match individual characters just once?
for example, i'd like to grep for the letters a, b and c in any order, but each letter should only appear once (or not at all) in the line.
can it be done?
Well, the short answer is probably "no." It would be useful to know the goal in building this match.
It's trivial to match a single character, just use
and you'll match the single character.
You have two challenges that I see. You only want the single characters and you want to match in any order. But is it your intention to extract the characters, or do you only want a boolean answer (yes they are there, no they aren't there)? And is it true only if all three are there?
These questions are why it is hard to answer without knowing the purpose of the exercise.
Also, for all questions regex, the indispensable tool is the regex coach. It's free as in free speech as well as in free beer, and provides you with an interactive GUI for playing with your regex.
Thanks.
mp
If you have to ask what jazz is, you'll never know. -- Louis Armstrong
Bookmarks