How do I determine the file extension of a file name string?
lets say I have
I'm.a.file.name.tXt
the regex should return tXt
something like \.[^.]*$ should do it
\. a lookbehind - so (?<=\.)[^.]*$ - to avoid potentially having to remove the . later. Though not all regex implementations support lookbehinds, and we don't know what one this is for.You probably don't need regex - most languages will have the equivalent to this:
ListLast(Filename,'.')
(If you do need regex for some reason, Scharron's answer is correct.)
/^(.*?)\.(.*)$/
The '?' makes it greedy. Your result will be in the second group.
? makes a quantifier lazy, not greedy!(greedy).(lazy) in order to consume as much as possible for the first group and as little as required for the second.
tXtevery time, rather thantxt?