Reputation: 44066
I have this test string
[list][*] This is [bracket text][/list]
I want to grab all the [*]
and after up until the last [
I am using this regex \[\*(:[^\[]+)?\]([^\[]+)
which only grabs till the first [
and leaving off the [bracket text]
part of the string
I need the match to be This is [bracket text]
Any thoughts on how to achieve this
Upvotes: 0
Views: 48
Reputation: 784998
You can use this greedy regex with a lookahead:
\[\*\] *(.*)(?=\[)
.*
is greedy to make sure to match until assertion of last [
using lookahead.
Upvotes: 2