I was able to match everything outside the square brackets using ([^\[\]]+)(?:$|(?=\[)), which gives me:
!Bat_Boy.png|thumbnail! !visagepaume.png|thumbnail!, Test comment: public., Test comment: internal., [^TEST_ATTACHMENT.txt], Test comment: public!, !visagepaume.png|thumbnail!, Test comment: internal!, [^TEST_ATTACHMENT.txt]
Is there a way to write a single regex that would also match outside two exclamation marks with a pipe in-between, in addition? This is to be used with a single java string replaceAll() method. Basically, I am looking for this result:
!Bat_Boy.png|thumbnail! !visagepaume.png|thumbnail!, Test comment: public., Test comment: internal., [^TEST_ATTACHMENT.txt], Test comment: public!, !visagepaume.png|thumbnail!, Test comment: internal!, [^TEST_ATTACHMENT.txt]
Notes: