What I'm trying to achieve is changing square brackets [] to curly/brace brackets {}.
There are two conditions, some start with [", the others end with "]
There will not be any occurrences where both exist in same string. Haven't run across any yet.
BEFORE:
[Strained breathing]
["Wanna Give My Love"
by The Sons of Rainier]
[Mavrick blows a fart]
["Hallelujah"
by The Sons of Rainer]
[Victor over the phone]
[The Korgi's "Everybody's
Got To Learn Sometime"]
[Lola chuckles]
["It's Good"
by Jack Hammer]
[Uno Hype's "Leave"]
Here's what I would like as the end results
AFTER:
[Strained breathing]
{"Wanna Give My Love"
by The Sons of Rainier playing}
[Mavrick blows a fart]
{"Hallelujah"
by The Sons of Rainer}
[Victor over the phone]
{The Korgi's "Everybody's
Got To Learn Sometime"}
[Lola chuckles]
{"It's Good"
by Jack Hammer}
{Uno Hype's "Leave"}
Here are my attempts:
Find: (?=\[")([\S\s] ?)\]
Replace: \{$1\}
Find: (?=\[[A-Z])([\S\s] ?)\"]
Replace: \{$1\}
Find: \["([A-Z][\S\s] ?)\]
Replace: \{$1\}
So frustrated that my light blub is still so dim in regards to regex.
Thanks in Advance
CodePudding user response:
You could use this regex:
\[("[^]] |[^]] ")\]
which matches a [
followed by either
- a
"
and some number of non-]
characters; or - some number of non-
]
characters followed by a"
and then followed by a ]
, and replace it with {\1}
.