doctest-ts/test/hasFoo.ts

14 lines
313 B
TypeScript
Raw Normal View History

2018-02-28 10:30:39 +01:00
/** Does this string contain foo, ignoring case?
hasFoo('___foo__') // => true
hasFoo(' fOO ') // => true
hasFoo('Foo.') // => true
hasFoo('bar') // => false
hasFoo('fo') // => false
hasFoo('oo') // => false
*/
function hasFoo(s: string): boolean {
2018-03-05 17:15:31 +01:00
return null != s.match(/foo/i)
2018-02-28 10:30:39 +01:00
}