code: public static Object indexOf(String strPattern, String strInput, int offset, boolean caseSensitive, boolean matchAll) throws MalformedPatternException {
  	// Perl5Compiler compiler = new Perl5Compiler();
  	PatternMatcherInput input = new PatternMatcherInput(strInput);
  	Perl5Matcher matcher = new Perl5Matcher();
  
  	int compileOptions = caseSensitive ? 0 : Perl5Compiler.CASE_INSENSITIVE_MASK;
  	compileOptions += Perl5Compiler.SINGLELINE_MASK;
  	if (offset < 1) offset = 1;
  
  	Pattern pattern = getPattern(strPattern, compileOptions);
  	// Pattern pattern = compiler.compile(strPattern,compileOptions);
  
  	if (offset <= strInput.length()) input.setCurrentOffset(offset - 1);
  
  	if (offset <= strInput.length()) {
  	    Array matches = new ArrayImpl();
  	    while (matcher.contains(input, pattern)) {
  		int match = matcher.getMatch().beginOffset(0) + 1;
  		if (!matchAll) {
  		    return new Double(match);
  		}
  
  		matches.appendEL(match);
  	    }
  
  	    if (matches.size() != 0) {
  		return matches;
  	    }
  	}
  	return 0;
      }
docs: return index of the first occurence of the pattern in input text
  
  @param strPattern pattern to search
  @param strInput text to search pattern
  @param offset
  @param caseSensitive
  @return position of the first occurence
  @throws MalformedPatternException