For example, I need everything in between the two square brackets. File1
[Home sapiens]
[Mus musculus 1]
[virus 1 [isolated from china]]
So considering the above example, I need everything in between the first and last square brackets.
If you want to extract part string between two same characters, you can do as this: Select a cell which you will place the result, type this formula =SUBSTITUTE(MID(SUBSTITUTE("/" & A3&REPT(" ",6),"/",REPT(",",255)),2*255,255),",",""), and press Enter key.
The easiest way to extract a substring between two delimiters is to use the text to column feature in Excel, especially if you have multiple delimiters. In this example, use =MID(A2, SEARCH(“-“,A2) + 1, SEARCH(“-“,A2,SEARCH(“-“,A2)+1) – SEARCH(“-“,A2) – 1) in cell B2 and drag it to the entire data range.
You can use a greedy regex:
re.search(r'\[(.*)\]', your_string).group(1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With