-1

In Textpad, is it possible to find the last occurence of a string within a string, so, for instance...

Find the last occurrence of _ within

FF_SF_FIRE_STRATEGY_G

So that you can then obtain either FF_SF_FIRE_STRATEGY or G

?

UPDATE: This solves half the problem: _[A-Z]\>

Strawberry
  • 33,750
  • 13
  • 40
  • 57

2 Answers2

0

You may use a negative lookahead based regex:

_(?!\S*_)

RegEx Demo

Here (?!\S*_) is a negative lookahead that asserts that we don't have any more _ following 0 or more non-whitespace characters on right hand side.

anubhava
  • 761,203
  • 64
  • 569
  • 643
0

According to textpad the regex syntax it used before v7 was POSIX and later it adopted Perl regular expressions. So best is to upgrade your textpad else the following regex attempts to match _ and captures its preceding / following non-whitespace characters:

\(^|[[:blank:]]\)\([^[:blank:]]*\)_\([^[:blank:]_]*\)\([[:blank:]]|$\)

It has 4 capturing groups and what you need is hold by \2 and \3.

See a Perl compatible demo here

revo
  • 47,783
  • 14
  • 74
  • 117