Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
lets say I have this sentence.

C#
string sSentence;
sSentence = "this is a string";


first thing I have to do in my program is to find the first vowel of each word.

for "this" the vowel is i.

is there a way for this function

str.find(key) can find this a,e,i,o,u ?

str.find(a || e || i || o || u);

please help thanks :))
Posted
Comments
Sergey Alexandrovich Kryukov 18-Feb-15 11:49am    
Just a note: this is formulated as a problem "find an English vowel". There much more vowels in the world. What is it: std::string for native C++ or managed System.String for C++/CLI?
—SA

1 solution

There std::string class gently provides the find_first_of[^] method.
 
Share this answer
 
Comments
Reuben Cabrera 18-Feb-15 11:12am    
uhm thank but i do not quite understand what it means. it was not taught to us. i wanna try and use str.find(___);
Ravi Bhavnani 18-Feb-15 11:16am    
> it was not taught to us
That's a terrible attitude. Google it. You won't get far developing software if you don't research and experiment.

/ravi
Sergey Alexandrovich Kryukov 18-Feb-15 11:51am    
Agree. This is the no-go attitude. It would be cheaper to give up engineering immediately, before having all this frustration and failures where such attitude can only lead. :-)
—SA
CPallini 18-Feb-15 11:26am    
If you cannot use str::find_first_of (because your teacher wouldn't like it) then you have to separately call str::find for each of the vowvels and then take the minimum result (or, alternatively, write your own implementation of find_first_of function).
Reuben Cabrera 18-Feb-15 11:25am    
well i kinda stated what I need. if there was a way to that with the function that I need then I might first try it before I go experimenting on other functions. Im also trying to learn on what other possibilities is there for str.find function.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900