Regex to remove '_1' from a specific pattern of keywords

Hi Team,

Can anyone please help me with some regex that will eliminate ‘_1’ which is at the extreme right position of the keyword from below pattern of text? -

Input String -

Q1_1 "
_1 "
Q1B_1 "
G1_1_1 "
PSM1_1 "
_1 "
PSM1_RESPONSE_1 "
DUMMY_PMS2_1 "
“_1”
Q11_1 "

Output String -

Q1 "
_1 "
Q1B "
G1_1 "
PSM1 "
_1 "
PSM1_RESPONSE "
DUMMY_PMS2 "
“_1”
Q11 "

give a try on following:
grafik

2 Likes

@ppr … This is working fine and exactly the regex I was looking for.
Can you please let me know what is that ‘?\b’ indicates at the end of the pattern?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.