-3

Extract all the string between 2 patterns:

Input:

test.output0    testx.output1    output3    testds.output2(\t)

Output:

output0    output1    ouput3   output2

Note: (" ") is the tab character.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • 1
    This will help `\.\w+(?=\t|$)`. See demo https://regex101.com/r/wK9MQ1/2 –  Jul 06 '20 at 05:57

2 Answers2

1

You may try:

\.\w+$

Explanation of the above regex:

  • \. - Matches . literally. If you do not want . to be included in your pattern; please use (?<=\.) or simply remove ..
  • \w+ - Matches word character [A-Za-z0-9_] 1 or more time.
  • $ - Represents end of the line.

You can find the demo of the regex in here.

Result Snap:

Pictorial Representation

EDIT 2 by OP:

According to your latest edit; this might be helpful.

.*?\.?(\w+)(?=\t)

Explanation:

  • .*? - Match everything other than new line lazily.
  • \.? - Matches . literally zero or one time.
  • (\w+) - Represents a capturing group matching the word-characters one or more times.
  • (?=\t) - Represents a positive look-ahead matching tab.
  • $1 - For the replacement part $1 represents the captured group and a white-space to separate the output as desired by you. Or if you want to restore tab then use the replacement $1\t.

Please find the demo of the above regex in here.

Result Snap 2:

enter image description here

-1

Try matching on the following pattern:

Find: (?<![^.\s])\w+(?!\S)

Here is an explanation of the above pattern:

(?<![^.\s])  assert that what precedes is either dot, whitespace, or the start of the input
\w+          match a word
(?!\S)       assert that what follows is either whitespace of the end of the input

Demo

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360