Description
\s?(?:RuleSet|Data):\[[^]]*](?:,?\s|$)
Replace with:
nothing

This regular expression will do the following:
- find substrings that look like
RuleSet:[text],
or Data:[{text}{text}...]
- allow you to replace these with anything, or in this case nothing
Example
Live Demo
https://regex101.com/r/eJ2aB5/1
Sample text
RuleSet:[text], Data:[{text}{text}...] RuleSet:[text], Data:[{text},{text},....] SomeText RuleSet:[{text}...], Data:[{text}...]
After Replace
SomeText
Explanation
NODE EXPLANATION
----------------------------------------------------------------------
\s? whitespace (\n, \r, \t, \f, and " ")
(optional (matching the most amount
possible))
----------------------------------------------------------------------
(?: group, but do not capture:
----------------------------------------------------------------------
RuleSet 'RuleSet'
----------------------------------------------------------------------
| OR
----------------------------------------------------------------------
Data 'Data'
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------
: ':'
----------------------------------------------------------------------
\[ '['
----------------------------------------------------------------------
[^]]* any character except: ']' (0 or more times
(matching the most amount possible))
----------------------------------------------------------------------
] ']'
----------------------------------------------------------------------
(?: group, but do not capture:
----------------------------------------------------------------------
,? ',' (optional (matching the most amount
possible))
----------------------------------------------------------------------
\s whitespace (\n, \r, \t, \f, and " ")
----------------------------------------------------------------------
| OR
----------------------------------------------------------------------
$ before an optional \n, and the end of a
"line"
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------