All Posts Create a Post  
0
votes
531
views
Regular expression to replace second occurrence of dot
Posted at 8 months ago / May 19, 2021, noon

String is Hello.world.hello. I wanted to replace the second occurrence of the dot with ‘_’. str = "Hello. world. Hello!" x = re.sub(r'^((.){1}).', r'\1_', str) #x = str.find(str.find('.') print(x) The …

146 7 7 0