import java.util.*; import java.lang.*; import java.io.*; import java.util.regex.*; class Ideone { { String s = "\t\t\tHello I am studying regex!\n\t\t\tThis is a line in the text.\n\t\t\t\tDon't need to add this line\n\t\tnor this line.\n\t\t\tBut this line should be included."; Pattern pattern = Pattern.compile("(?:\\G(?!^)\\h+|^\t{3})(\\S+)", Pattern.MULTILINE); Matcher matcher = pattern.matcher(s); while (matcher.find()){ } } }
Standard input is empty
Match: 'Hello', Start: 3 Match: 'I', Start: 9 Match: 'am', Start: 11 Match: 'studying', Start: 14 Match: 'regex!', Start: 23 Match: 'This', Start: 33 Match: 'is', Start: 38 Match: 'a', Start: 41 Match: 'line', Start: 43 Match: 'in', Start: 48 Match: 'the', Start: 51 Match: 'text.', Start: 55 Match: 'But', Start: 113 Match: 'this', Start: 117 Match: 'line', Start: 122 Match: 'should', Start: 127 Match: 'be', Start: 134 Match: 'included.', Start: 137