Clint Mohamed
Clint Mohamed

Reputation: 59

Extract the last word from the first line

I want to capture the last word from the first line only not including the subsequent lines. I have the pattern below but it captures all the last words from all lines…

Here’s my pattern: https://regex101.com/r/pgU14C/1

Data:
*A* abcd efgh ijkl         Word
djdjfjfjfjfjfkfkfkfk       agjfj
gjfjfjfjfkfkffk            sjfjfj

Desired Match: Word

Upvotes: 0

Views: 185

Answers (1)

NullVoid
NullVoid

Reputation: 847

Just delete the global flag and u will get ur desired output:

/\w+$/m

Upvotes: 1

Related Questions