I have an array of strings that I want to extract specific content from:
['link.description', 'button.text]] </li>']
I want to get the following output:
link.description
button.text
For each string in the array, I do the following:
str = re.findall('(.*?)\]+', str)
With the above regex, I can only get button.text. How would I get both link.description and button.text? I tried using:
str = re.findall('(.*?)\]*', str)
But the above just gives me a bunch of blanks in the return str.
You don’t need regex for a simple task like this. Besides, your code will probably make more sense without regex.
In this case, you can simply use
str.split():