1

" :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

Brother85
  • 73
  • 3
  • 10

1 Answers1

0

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'
piRSquared
  • 285,575
  • 57
  • 475
  • 624