Let’s say I have a long string with address data in format:
string = ... 'Something 3; Place: Something; City: NewYork; Street: Broadway; House: 7; Lat g: 33,105438; Long g: 12,749558; Object: Something;'...
I want to extract substring from that string starting from Place: to Long g: 12,749558. usinge regex findall().
Can anyone help me? Thanks!
I want to get from my string:
Place: Something; City: NewYork; Street: Broadway; House: 7; Lat g: 33,105438; Long g: 12,749558;
>Solution :
You can use the following regex pattern: r'Place:.*?Long g: \d+,\d+;'.
Code example:
import re
string = '... Something 3; Place: Something; City: NewYork; Street: Broadway; House: 7; Lat g: 33,105438; Long g: 12,749558; Object: Something;...'
pattern = r'Place:.*?Long g: \d+,\d+;'
result = re.findall(pattern, string) # "Place: Something; City: NewYork; Street: Broadway; House: 7; Lat g: 33,105438; Long g: 12,749558;"