function nextWordHelper(text, indexAfter, re, defaultValue) {
  if (text === undefined) {
    return defaultValue;
  }
  let result = re.exec(text.substr(indexAfter));
  if (result != null && result.length > 0) {
    return indexAfter + result.index;
  }
  return defaultValue;
}
/**
 * Searches through text to find the first index of a regular expression
 * after a given starting index. Returns a default value if no match is
 * found.
 * @param {string|undefined} text The string to search through
 * @param {number} indexAfter The index at which to start searching
 * @param {RegExp} re A regular expression to search for
 * @param {number} defaultValue The default value to return if no
                     match is found.
 * @return {number} The index found by the regular expression, or -1
 *                    if none found.
 */
Searches through text to find the first index of a regular expression
after a given starting index. Returns a default value if no match is
found.
@param {string|undefined} text The string to search through
@param {number} indexAfter The index at which to start searching
@param {RegExp} re A regular expression to search for
@param {number} defaultValue The default value to return if no
match is found.
@return {number} The index found by the regular expression, or -1
if none found.
Searches through text to find the first index of a regular expression after a given starting index . Returns a default value if no match is found . @param { string|undefined } text The string to search through @param { number } indexAfter The index at which to start searching @param { RegExp } re A regular expression to search for @param { number } defaultValue The default value to return if no match is found . @return { number } The index found by the regular expression or - 1 if none found .
function nextWordHelper(text, indexAfter, re, defaultValue) {
  if (text === undefined) {
    return defaultValue;
  }
  let result = re.exec(text.substr(indexAfter));
  if (result != null && result.length > 0) {
    return indexAfter + result.index;
  }
  return defaultValue;
}
function nextWordHelper ( text , indexAfter , re , defaultValue ) { if ( text === undefined ) { return defaultValue ; } let result = re . exec ( text . substr ( indexAfter ) ) ; if ( result != null && result . length > 0 ) { return indexAfter + result . index ; } return defaultValue ; }
Searches through text to find the first index of a regular expression
 after a given starting index.
Searches through text to find the first index of a regular expression after a given starting index .