如何获得字符串中字符的倒数第二次?
我想用它从aaa
www.example.com/example/abc/aaa
答案 0 :(得分:0)
我喜欢正则表达式:
import re
p = re.compile('a')
all_positions = [oMatch.span() for oMatch in p.finditer(sText)]
second_last_position_span = all_positions[-2]
second_last_position_start_index = second_last_position_span[0]