Home > Mobile >  extract data between single quotes
extract data between single quotes

Time:12-01

trying to extract the data between single quotes

import re 

a = 'USA-APA HA-WBS-10.152.08.0/24'

print(re.findall(r'()', a))

expecting the oputput : USA-APA HA-WBS-10.152.08.0/24

CodePudding user response:

What is wrong with ? It is just a string ?

a = 'USA-APA HA-WBS-10.152.08.0/24'
print(a)

Output:

%  python3 test.py
USA-APA HA-WBS-10.152.08.0/24

You might want to look at this also regarding quotes and strings:

Single and Double Quotes | Python

CodePudding user response:

I am not very familiar with python but with some quick searching around I've found that this work

import re

a = 'USA-APA HA-WBS-10.152.08.0/24'
result = re.findall(r'(.*?)', a)
print("".join(result))

I'm pretty sure there are better ways of solving this but I'm not familiar with the language

  • Related