How to find all double quote substrings in a string with Python

1 Answer

0 votes
import re

# Define the string
str_value = 'This is a string with "double-quoted substring1", and "double-quoted substring2" inside.'

# Regular expression pattern to match substrings within double quotes
pattern = r'"([^"]*)"'

# Find all matches
substrings = re.findall(pattern, str_value)

print(substrings)

 
 
'''
run:
 
['double-quoted substring1', 'double-quoted substring2']
 
'''

 



answered May 13 by avibootz
...