简体   繁体   English

如何在 Python 中最后一次出现非数字字符后获取所有数字

[英]How to get all numbers after the last occurrence of a non numeric character in Python

Say I have the string说我有字符串

100D555 100D555

How can I split this string in python to be left only with '555' at the end?如何将 python 中的这个字符串拆分为最后只留下“555”? The strings I am operating on follow the same format roughly: x amount of numbers, followed by one non numeric char, followed by z amount of numbers.我操作的字符串大致遵循相同的格式:x 个数字,后跟一个非数字字符,然后是 z 个数字。 Another example:另一个例子:

10M4567 In this case I would want '4567' 10M4567 在这种情况下,我想要“4567”

Say I have the string说我有字符串

100D555 100D555

How can I split this string in python to be left only with '555' at the end?如何将 python 中的这个字符串拆分为最后只留下“555”? The strings I am operating on follow the same format roughly: x amount of numbers, followed by one non numeric char, followed by z amount of numbers.我操作的字符串大致遵循相同的格式:x 个数字,后跟一个非数字字符,然后是 z 个数字。 Another example:另一个例子:

10M4567 In this case I would want '4567' 10M4567 在这种情况下,我想要“4567”

Say I have the string说我有字符串

100D555 100D555

How can I split this string in python to be left only with '555' at the end?如何将 python 中的这个字符串拆分为最后只留下“555”? The strings I am operating on follow the same format roughly: x amount of numbers, followed by one non numeric char, followed by z amount of numbers.我操作的字符串大致遵循相同的格式:x 个数字,后跟一个非数字字符,然后是 z 个数字。 Another example:另一个例子:

10M4567 In this case I would want '4567' 10M4567 在这种情况下,我想要“4567”

Say I have the string说我有字符串

100D555 100D555

How can I split this string in python to be left only with '555' at the end?如何将 python 中的这个字符串拆分为最后只留下“555”? The strings I am operating on follow the same format roughly: x amount of numbers, followed by one non numeric char, followed by z amount of numbers.我操作的字符串大致遵循相同的格式:x 个数字,后跟一个非数字字符,然后是 z 个数字。 Another example:另一个例子:

10M4567 In this case I would want '4567' 10M4567 在这种情况下,我想要“4567”

Say I have the string说我有字符串

100D555 100D555

How can I split this string in python to be left only with '555' at the end?如何将 python 中的这个字符串拆分为最后只留下“555”? The strings I am operating on follow the same format roughly: x amount of numbers, followed by one non numeric char, followed by z amount of numbers.我操作的字符串大致遵循相同的格式:x 个数字,后跟一个非数字字符,然后是 z 个数字。 Another example:另一个例子:

10M4567 In this case I would want '4567' 10M4567 在这种情况下,我想要“4567”

Say I have the string说我有字符串

100D555 100D555

How can I split this string in python to be left only with '555' at the end?如何将 python 中的这个字符串拆分为最后只留下“555”? The strings I am operating on follow the same format roughly: x amount of numbers, followed by one non numeric char, followed by z amount of numbers.我操作的字符串大致遵循相同的格式:x 个数字,后跟一个非数字字符,然后是 z 个数字。 Another example:另一个例子:

10M4567 In this case I would want '4567' 10M4567 在这种情况下,我想要“4567”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在最后一个字符出现后获取所有内容 - get everything after last character occurrence python Python正则表达式:替换所有出现的特定字符串,而不是在特定字符之后 - Python regex: substitute all occurrence of a certain string NOT after a specific character 在pandas中最后一次出现特定值后获取所有行 - Get all rows after the last occurrence of a specific value in pandas 如何在最后一次出现值后删除所有行? - How do I drop all rows after last occurrence of a value? Python:如何将非数字字符转换为空格 - Python: How do i convert non numeric character into blank space python:如何拆分列表中的非数字字符? - python : how to split the non-numeric character in lists? 如何在不包括最后一个实例的字符的倒数第二个实例之后获取所有文本? - How to get all text after the second to last instance of a character excluding the last instance? 获取第一个数字字符 python 正则表达式之前的所有字符串 - get all the string before first numeric character python regex 在Python中最后一次出现给定字符之后,找到字符串字符的最简单方法是什么? - What is the easiest way of finding the characters of a string after the last occurrence of a given character in Python? 如何获取 python 中数组的第一个和最后一个匹配项? - How to get the first and the last matching occurrence of an array in python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM