All Posts Create a Post  
0
votes
23
views
Regular expression to replace second occurrence of dot
Posted at 1 month 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 …

172 2 2 0