I need to capture words separated by tabs as illustrated in the image below.

enter image description here

The expression (.*?)[\t|\n] works well, except for the last line where a line feed is missing. Can anyone suggest a modification of the regular expression to also match the last word, i.e. Cheyenne? Link to code example

1 Answers

wjandrea On Best Solutions

Replace [\t|\n] with (\t|$).

BTW, [\t|\n] is a character class, so the pipe | is literal here. You probably meant [\t\n].