user3022875
user3022875

Reputation: 9018

Regex to find text after period

Do you know what the regex expression would be to find the last text after a period.

exampels

 this.is.a.test = test
 GOOG.N.QQ.HH = HH

Any ideas?

Thank you.

Upvotes: 3

Views: 17498

Answers (4)

Jongware
Jongware

Reputation: 22457

Short and simple: a list of characters at the end of a line, not containing the full stop:

[^.]+$

Since GREP is greedy by default, it will match as much as possible characters, so for these two test strings it will return everything after the last full stop until the end-of-string.

Upvotes: 11

kums
kums

Reputation: 2691

If you want the last word of the quadruple

(?<=\.)(\w+)(?=\s*=)

Demo

Upvotes: 0

Bohemian
Bohemian

Reputation: 425003

This will match text following the last dot, or the whole string if there are no dots:

(?<=\.|^)[^.]+$

The whole match is your target, because a (non-capturing) look behind is used to assert the match is preceded by a dot or start-of-input.

See demo

Upvotes: 1

aaronfc
aaronfc

Reputation: 165

Maybe you should go with something like: \.([^\.]+)$

Hope it helps!

Upvotes: 0

Related Questions