2021年1月18日星期一

Regex - Grab everything between multiple brackets ([])

I'm struggling to get a regex string working to where I can grab the groups and see if they equal a specific string.

My goal;

String I'm using:

[TEXT]&8/&7Nations create &8[&aName&8][/TEXT][HOVER]&7Click to run this command.[/HOVER][SUGGEST]/nations create [/SUGGEST]  

I want to grab [TEXT][/TEXT] [HOVER][/TEXT] [SUGGEST][/SUGGEST] and everything in-between them. Each string inbetween them will do something different.

As you notice, the text in-between can contain [] also. I do not want to grab these. only the placeholders I listed above.

Only regex patterns I've came up with so far;

\[([^\[\]]|)*\]  \[(.+?)]([^]\]].+)\[(.+?)]  \[(.+?)](.+)\[(.+?)]  
https://stackoverflow.com/questions/65785309/regex-grab-everything-between-multiple-brackets January 19, 2021 at 12:01PM

没有评论:

发表评论