Javascript Regex for a partial string match only

javascript, match, partial, regex, string

Solution

You want to use a non-word boundary `\B` here.

/\Batta|atta\B/

Problem

I need to write a JavaScript RegEx that matches only the partial strings in a word. For example if I search using the string 'atta' it should return ``` true for khatta true for attari true for navrattan false for atta ``` I am not able to figure how to get this done using one RegEx. Thanks!

Original source