Issue with regex search python
1 min read
My string is:
test_string = "@@@__slug1^^__firstname [email protected]@@^^^ @@@__slug2^^__firstname1 [email protected]@@^^^"
I am trying to separate slug and lastname in a list my output will be like.
slug_list = [slug1,slug2]
name_list=[firstname lastname,firstname1 lastname1]
I try to first search all the slug my code for the same is.
import re
test_string = "@@@__slug1^^__firstname [email protected]@@^^^ @@@__deletepurpose^^__Delete [email protected]@@^^^"
pattern = "@@@__|(''*?)|^^"
substring = re.search(pattern, test_string).group(1)
print(substring)
But it is giving me error.
AttributeError: 'NoneType' object has no attribute 'group'
資料來源:Stackoverflow