Question:We need to extract characters from scattered data with more than one separator and quite a few spaces, for example:
The original string is as follows:
'asd ff gg; asd , foo| og '
We need to remove the above, ;| separator and extra spaces and extract the:
['asd', 'ff', 'gg', 'asd', 'foo', 'og']
This is generally used to deal with logs or web page data extraction, in general, the data distribution required in this kind of data is not too regular and scattered.
The results of the process are as follows:
import re line = 'asd ff gg; asd , foo| og ' data = (r'[;,|\s]\s*',line) for i in data: if i == '': (i) print(data)
Above this python for indeterminate delimiter cut to extract the string is all I have shared with you, I hope to give you a reference, and I hope you support me more.