I have a large numpy array of strings, where some elements of the array are good strings, some have special characters (typically at the start of the string and some have substrings in various quotes inside of it). I want to identify the elements which have a string inside of the string, store the string inside and remove it from my original string.
example:
my_array = ['# this is the "Sharpest" hashtag ever', 'life as we know it', '" what would you do?', 'this was an "arbitrary" result', 'what do you mean']
corrected_array = ['# this is the hashtag ever', 'life as we know it', '" what would you do?',
'this was an result', 'what do you mean']
As you can see the words "Sharpest" and "arbitrary" were removed from the corrected array. Is there a way where I can identify the substrings and remove them from my original string efficiently
my_arrayare invalid, causing a syntax error. You're going to have to fix that while you build that list. Show the code for howmy_arrayis created.'# this is the 'Sharpest' hashtag ever'is an invalid string, so you probably have to change the encasing quotes for the string or the substring