Java tutorial
//package com.java2s; import java.util.Vector; public class Main { private static int extractConditionsOperatorTokens(String relevant, int startPos, Vector<String> list) { int pos, pos2, opSize = 5; pos = relevant.toUpperCase().indexOf(" AND ", startPos); if (pos < 0) { pos = relevant.toUpperCase().indexOf(" OR ", startPos); opSize = 4; } pos2 = relevant.toUpperCase().indexOf(" OR ", startPos); if (pos2 > 0 && pos2 < pos) { pos = pos2; opSize = 4; } if (pos < 0) { list.add(relevant.substring(startPos).trim()); opSize = 0; } else list.add(relevant.substring(startPos, pos).trim()); return pos + opSize; } }