Например у меня есть:
Apple:123456789:pear
watermelon:57952161354:kfc
Как мне удалить текст до и после ":", чтобы получить это:
123456789
57952161354
^[^:]+:([^:]+):[^:]+$$1Объяснение:
^               # beginning of line
    [^:]+:      # 1 or more any character that is not colon followed by 1 colon
    ([^:]+)     # group 1, 1 or more any character that is not colon
    :[^:]+      # 1 colon followed by 1 or more any character that is not colon
$               # end of line
Замена:
$1  # content of group 1 (i.e. the digits)
Результат для данного примера:
123456789
57952161354