huarte 发表于 2017-04-10 11:44

正则,请问怎么取最后一个冒号后边的数字?如 ::1:25

::1:25正则表达式怎么取到最后一个冒号后面的数字

Lemon_乐 发表于 2017-04-10 13:24

Lemon_乐 发表于 2017-04-10 13:27

zxy877298415 发表于 2017-04-10 14:15

回复 1# huarte


re.search(r'[^:]+
,'::1:25').group()

ssfjhh 发表于 2017-04-10 21:27

'::1:25'.rpartition(':')[-1]

MMMIX 发表于 2017-04-11 21:06

回复 1# huarte



Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.

MMMIX 发表于 2017-04-11 21:06

回复 1# huarte



Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.

MMMIX 发表于 2017-04-11 21:07

回复 1# huarte


Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.

MMMIX 发表于 2017-04-11 21:07

回复 1# huarte

Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.

MMMIX 发表于 2017-04-11 21:10

不是出错了么?怎么都成功了?
页: [1] 2
查看完整版本: 正则,请问怎么取最后一个冒号后边的数字?如 ::1:25