" :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
Asked
Active
Viewed 145 times
1
-
`:\S+ \S+_LCAppendedButton` regex will match what you are trying to match. – TeWu May 02 '16 at 17:23
1 Answers
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