In the following string,how to match the words including the commas
-
—
process_str = "Marry,had ,a,alittle,lamb" import re re.findall(r".*",process_str) ['Marry,had ,a,alittle,lamb', ''] -
—
process_str="192.168.1.43,Marry,had ,a,alittle,lamb11" import re ip_addr = re.findall(r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}",l) re.findall(ip_addr,process_str1)How to find the words after the ip address excluding the first comma only
i.e, the outout again is expected to beMarry,had ,a,alittle,lamb11 -
In the second example above how to find if the string is ending with a digit.
In the second example, you just need to capture (using
()) everything that follows the ip:To find out if the string ends with a digit, you can use the following:
That is, you match the entire string (
.*), and then backtrack to test if the last character (using$, which matches the end of the string) is a digit.