So let's say I have a piece of text: Note: this is a file I'm reading in so it isn't actually commented out in the code
" ## BATTERY LIFE: Pretty medicore at 12 hours, the Creative, iAudio, Rio, and iRiver players last longer.
CUSTOMER SERVICE[-3]## CUSTOMER SERVICE: Awful. Listen to this one, remember the battery statement I made earlier.
##If your battery dies and it's still under warranty, guess what, you're out of luck, because Apple doesn't cover the battery in the iPod warranty.
##They have the nerve to charge you $30 for a warrantied iPod.
technical service[-3]## "
And I want to extract the elements just before the square brackets, for example, in this piece of text I would like: CUSTOMER SERVICE[-3] and technical service[-3]
Is there any cool way to got about doing this (using some application of Regex) because I'm stumped at the moment.
CodePudding user response:
Addressed in regex way.
Demo: https://regex101.com/r/mWsAHf/1
Pattern: \w \w \[-?\d ]