• 5315阅读
  • 1回复

关于QString 下 indexOf()的问题 [复制链接]

上一主题 下一主题
离线powerdarksky
 

只看楼主 倒序阅读 楼主  发表于: 2009-06-23
indexOf("a",0)是从0位开始查找a这个字符串所在的位置,如果需要从0位开始查找"a"或者"b"所在的位置,应该怎么写?还是必须用if else的?
离线sentimental
只看该作者 1楼 发表于: 2009-06-23
看下这个函数

nt QString::indexOf ( const QRegExp & rx, int from = 0 ) const

This function overloads indexOf().

Returns the index position of the first match of the regular expression rx in the string, searching forward from index position from. Returns -1 if rx didn't match anywhere.

Example:

     QString str = "the minimum";
     str.indexOf(QRegExp("m[aeiou]"), 0);       // returns 4



QRegExp里可以用正则
快速回复
限100 字节
 
上一个 下一个