I would like to extract from a string the words that are before colon (:) but without the \n characters
I have the following string:
enx002: connected to Wired connection 2
docker0: connected to docker0
virbr0: connected to virbr0
tun0: connected to tun0
I would like to extract the words before :
I used a regular expression:
pattern = '[^:-].*?:\s*'
xx = re.findall(pattern, stringfromabove)
I do get a list of strings as expected just that they are taking also : at the end as well \n example: xx[3] will be '\ntun0: '
What I want is to be just 'tun0'
thank you for the help