【发布时间】:2012-07-23 09:24:57
【问题描述】:
我想检查一个字符串是否存在于另一个字符串中,然后采取适当的措施。最好的方法是什么?
例如;如果字符串 'europe' 出现在 'europeisthebest' 中,则执行一些操作。
if ( isIn('europe', 'europeisthebest') == true){
//do something
}
非常感谢!感谢您的所有回答和花时间提供的帮助。
【问题讨论】:
我想检查一个字符串是否存在于另一个字符串中,然后采取适当的措施。最好的方法是什么?
例如;如果字符串 'europe' 出现在 'europeisthebest' 中,则执行一些操作。
if ( isIn('europe', 'europeisthebest') == true){
//do something
}
非常感谢!感谢您的所有回答和花时间提供的帮助。
【问题讨论】:
【讨论】:
if( strpos('blah', 'blah') !== false ).
如果您想知道字符串中子字符串的位置,也可以使用函数 strpos()
【讨论】: