public static Struct find(String strPattern,String strInput,int offset,boolean caseSensitive) throws MalformedPatternException {
  Perl5Matcher matcher=new Perl5Matcher();
  PatternMatcherInput input=new PatternMatcherInput(strInput);
  int compileOptions=caseSensitive ? 0 : Perl5Compiler.CASE_INSENSITIVE_MASK;
  compileOptions+=Perl5Compiler.SINGLELINE_MASK;
  if (offset < 1)   offset=1;
  Pattern pattern=getPattern(strPattern,compileOptions);
  if (offset <= strInput.length())   input.setCurrentOffset(offset - 1);
  if (offset <= strInput.length() && matcher.contains(input,pattern)) {
    MatchResult result=matcher.getMatch();
    int groupCount=result.groups();
    Array posArray=new ArrayImpl();
    Array lenArray=new ArrayImpl();
    for (int i=0; i < groupCount; i++) {
      int off=result.beginOffset(i);
      posArray.appendEL(Integer.valueOf(off + 1));
      lenArray.appendEL(Integer.valueOf(result.endOffset(i) - off));
    }
    Struct struct=new StructImpl();
    struct.setEL("pos",posArray);
    struct.setEL("len",lenArray);
    return struct;
  }
  Array posArray=new ArrayImpl();
  Array lenArray=new ArrayImpl();
  posArray.appendEL(Constants.INTEGER_0);
  lenArray.appendEL(Constants.INTEGER_0);
  Struct struct=new StructImpl();
  struct.setEL("pos",posArray);
  struct.setEL("len",lenArray);
  return struct;
}

public static Struct find ( String strPattern , String strInput , int offset , boolean caseSensitive ) throws MalformedPatternException { Perl5Matcher matcher = new Perl5Matcher ( ) ; PatternMatcherInput input = new PatternMatcherInput ( strInput ) ; int compileOptions = caseSensitive ? 0 : Perl5Compiler . CASE_INSENSITIVE_MASK ; compileOptions += Perl5Compiler . SINGLELINE_MASK ; if ( offset < 1 ) offset = 1 ; Pattern pattern = getPattern ( strPattern , compileOptions ) ; if ( offset <= strInput . length ( ) ) input . setCurrentOffset ( offset - 1 ) ; if ( offset <= strInput . length ( ) && matcher . contains ( input , pattern ) ) { MatchResult result = matcher . getMatch ( ) ; int groupCount = result . groups ( ) ; Array posArray = new ArrayImpl ( ) ; Array lenArray = new ArrayImpl ( ) ; for ( int i = 0 ; i < groupCount ; i ++ ) { int off = result . beginOffset ( i ) ; posArray . appendEL ( Integer . valueOf ( off + 1 ) ) ; lenArray . appendEL ( Integer . valueOf ( result . endOffset ( i ) - off ) ) ; } Struct struct = new StructImpl ( ) ; struct . setEL ( "pos" , posArray ) ; struct . setEL ( "len" , lenArray ) ; return struct ; } Array posArray = new ArrayImpl ( ) ; Array lenArray = new ArrayImpl ( ) ; posArray . appendEL ( Constants . INTEGER_0 ) ; lenArray . appendEL ( Constants . INTEGER_0 ) ; Struct struct = new StructImpl ( ) ; struct . setEL ( "pos" , posArray ) ; struct . setEL ( "len" , lenArray ) ; return struct ; }
find occurence of a pattern in a string ( same like indexof ) , but dont return first ocurence , it return struct with all information
