0

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

asked Nov 30, 2022 at 9:03
2
  • What is your expected output here? Commented Nov 30, 2022 at 9:04
  • USA-APA HA-WBS-10.152.08.0/24 Commented Nov 30, 2022 at 9:07

2 Answers 2

1

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

answered Nov 30, 2022 at 9:23
Sign up to request clarification or add additional context in comments.

Comments

0

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

answered Nov 30, 2022 at 9:28

2 Comments

... or just print(a)
Yes as I said I'm unfamiliar with python and the case aswell. Maybe he wanted to find in a big text with double quotes all the texts with single quotes. I dunno :(

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.