Regular expression for ignoring the First set of letters or a word in a object name in python

156 Views Asked by At

" :NYSE Connect_LCAppendedButton " is the object name in our application which keeps changing. The set of words before _LCAppendedButton keeps changing according to our application needs. How do we ignore those set of word "NYSE Connect" or replace with regular expression? Pleae help

1

There are 1 best solutions below

0
On

Solution

import re

def replace_button_prefix(btn_pfix):
    return re.sub(r'^.*(_LCAppendedButton)$', r'\1', btn_pfix)

Demonstration

replace_button_prefix(" :NYSE Connect_LCAppendedButton")

'_LCAppendedButton'