Using the Perl regex engine, I can't figure out how to extract the last item in a line where items are split using the TAB character.

Here's an example from the Process Explorer log file:

^advapi32.dll\tAdvanced Windows 32 Base API\tMicrosoft Corporation\t5.1.2600.5755\tC:\WINDOWS\system32\advapi32.dll$

I tried the following, to no avail:

  • \t\w$: "Search string '\t\w$' not found!". Makes sense, as "\" isn't taken into account
  • \t[^\t].+?$: Starts from the second column
  • [^\t].+?$: Whole line

Any idea?

Thank you.


Use greediness of the wildcards: they will eat up as much as the can. For example if you want to match a whole line, use: ^.*\t([^\t]+)$. The ^.*\t matches everything that precedes a tab (including it) and the ([^t]+)$ group matches what you are looking for (and you can reference it with $1 in this case).


You were not far : very simply \t[^\t]+$ (or \t([^\t]+)$ if you can capture group from the result (the group you're looking for is inside the parenthesis)

  • Thanks but I tried "\t([^\t]+)$" and it simply removes the last\t before the last item – OverTheRainbow Nov 19 '12 at 13:59
  • Can you explain further what you're doing with these regexp, exactly ? Because I can assure you that this one matches what you need. – Orabîg Nov 19 '12 at 14:42
  • Ok, forget it. I just saw you gave credit to another one... – Orabîg Nov 19 '12 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.