You are not logged in.
Hello all, I've been working on this for quite some time now. I need to use a regular expression to find words that contain more than two vowels. I am getting stuck.
Here is what I have so far. I am using emacs to find them in a text file.
I use C-M-s and the expression /<[^aeiou]*[aeiou][^aeiou]/>
It finds words with one vowel, but I need to find if it has more than two, and I'm not sure how to go about doing that.
Any help is appreciated!
Offline
I've never used emacs, but grep seems to work with
LANG=C egrep '^([^aieou]*[aieou]){3,}[^aieou]*$' <filename>
modified from http://matt.might.net/articles/sculpting-text/
Edit: '{3,}' means simply 'three or more' of the preceding element.
Last edited by karol (2012-05-03 18:31:43)
Offline
This better not be a homework question...
[aeiou].*[aeiou].*[aeiou]
or, more succinctly (I think...)
\([aeiou].*\)\{3\}
I tested it with grep on a file with one word per line. Seems to work in that context. More than one word per line and it breaks. I know nothing of emacs or your data, so I have no idea if it will suffice.
I'd also suggest you go back over your expression and put into words exactly what you think it is doing. I'm no regex expert, but it doesn't seem at all fit for what you're trying to do.
But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner
Offline
I tested it with grep on a file with one word per line. Seems to work in that context. More than one word per line and it breaks.
Works here:
$ egrep '^([^aieou]*[aieou]){3,}[^aieou]*$' t1
aaa uuui
aaa bbb
bbaa bbaaiuo
Offline
Yeah, but he wants words, not lines. My suggestion also matches the line
adste e
for example.
But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner
Offline
This better not be a homework question...
[aeiou].*[aeiou].*[aeiou]
or, more succinctly (I think...)
\([aeiou].*\)\{3\}
I tested it with grep on a file with one word per line. Seems to work in that context. More than one word per line and it breaks. I know nothing of emacs or your data, so I have no idea if it will suffice.
I'd also suggest you go back over your expression and put into words exactly what you think it is doing. I'm no regex expert, but it doesn't seem at all fit for what you're trying to do.
Thanks that seemed to work!
Offline
WFM:
grep -P '\b([a-z]*[aeiou][a-z]*){2,}\b' *
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
sed -nr '/([aeiou][a-z]*){3}/p'
Last edited by zorro (2012-05-05 19:27:39)
Offline
FWIW, y is also a vowel, just ask any psychotic ;^)
Offline
FWIW, y is also a vowel, just ask any psychotic ;^)
What is a vowel differs from language to language.
Offline