/^\.(\w+).+$\^\t+\.\w+\W+(\w+)/m #### /(?:^|\n)\.(\w+).+\n\t+\.\w+\W+(\w+)/m #### /(?:^|\n) # Start matching either at the start of the string # or at a newline. The ?: part means, that # the parentheses I use don't get saved in $1 \.(\w+).+\n # match a line starting with a dot-word and some # more stuff \t+\.\w+ # The line after this must start with at least one # tab and then a dot-word \W+(\w+) # and contain some other stuff as well ... /mx