doctest-ts/test/hasFoo.ts
2018-03-05 17:15:31 +01:00

13 lines
313 B
TypeScript

/** 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 {
return null != s.match(/foo/i)
}