如何使用str.find在字符串中查找元音 [英] how to find a vowel in a string using str.find

查看:112
本文介绍了如何使用str.find在字符串中查找元音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想说这句话。



<前lang =cs> 字符串 sSentence ;
sSentence = 这是一个字符串;





我在程序中要做的第一件事就是找到每个单词的第一个元音。



for 这个元音是我。



有这种功能吗



str.find(key)可以找到这个, e,i,o,u?



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



请帮助谢谢:))

解决方案

std :: string class轻轻提供 find_first_of [ ^ ]方法。


lets say I have this sentence.

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 :))

解决方案

There std::string class gently provides the find_first_of[^] method.


这篇关于如何使用str.find在字符串中查找元音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆