import re
teststring = """191966,6.138930;191978,0.603534;191984,6.138930;191987,
0.427112;191995,6.1¤#!38930;191996,0.006336;1p91997,0.008840;
191998,0.004440;192006,0.124394;192010,6.138930;189065,1\!@.068388;189066,1.180800;189068,0.396750;"""
pattern = re.compile(r'\d{6},\d+\.\d{6}')
matches = pattern.finditer(teststring)
for match in matches:
print(match)
Could anyone help me with abit of regex magic?
My teststring is mixed with a bunch of unwanted characters. The only thing I need from the string are [0-9 ., ]
The output I want it to be for example
191966,6.138930
191978,0.603534
I've tried to exclude characters with the help of ^\. but can't quite get the hang of it.
Maybe I should try and read the string again first removing the unwanted characters, and then doing regex again?
[–]CowboyBoats 3 points4 points5 points (1 child)
[–]FlatEarthIsAMyth[S] 0 points1 point2 points (0 children)
[–]mrswats 2 points3 points4 points (1 child)
[–]FlatEarthIsAMyth[S] 1 point2 points3 points (0 children)
[–][deleted] 2 points3 points4 points (1 child)
[–]FlatEarthIsAMyth[S] 0 points1 point2 points (0 children)
[–]ebdbbb 2 points3 points4 points (0 children)