private static Object getNextMatchPosRegExImpl(String regEx,
							CharSequence searchIn, boolean goForward,
							boolean matchCase, boolean wholeWord,
							String replaceStr) {

		if (wholeWord) {
			regEx = "\\b" + regEx + "\\b";
		}

		// Make a pattern that takes into account whether or not to match case.
		int flags = Pattern.MULTILINE; // '^' and '$' are done per line.
		flags |= matchCase ? 0 : (Pattern.CASE_INSENSITIVE|Pattern.UNICODE_CASE);
		Pattern pattern = Pattern.compile(regEx, flags);

		// Make a Matcher to find the regEx instances.
		Matcher m = pattern.matcher(searchIn);

		// Search forwards
		if (goForward) {
			if (m.find()) {
				if (replaceStr==null) { // Find, not replace.
					return new Point(m.start(), m.end());
				}
				// Otherwise, replace
				return new RegExReplaceInfo(m.group(0),
						m.start(), m.end(),
						getReplacementText(m, replaceStr));
			}
		}

		// Search backwards
		else {
			List matches = getMatches(m, replaceStr);
			if (!matches.isEmpty()) {
				return matches.get(matches.size()-1);
			}
		}

		return null; // No match found

	}