// Suche nach ../ in den pageURLs String regex = "^(\\.\\./)*"; Pattern pat = new Pattern(regex, REFlags.IGNORE_CASE); Matcher mat = pat.matcher(pageURL); mat.matches(); int groupCount = mat.groupCount(); return ""+groupCount; URL: ../../../../test/blubb Count: 2