3-5-13d1140+regex+to+reformat+a+hyphenated+heirarchical+list+into+Java+like+code+so+that+it+can+be+viewed+in+an+IDE

regex to reformat a hyphenated ("bulleted") heirarchical list into Java like code so that it can be viewed in an IDE. Once in an IDE the text information will be collapsable and navigatable.

find regex (^(?<!-)-{2}(?!-))(.+?(?=[\r\n]))([\s\S\r\n]+?)(?=(^(?<!-)-{1,2}(?!-))) replace regex $1class $2\r{$3}\r

Note that this regex must be run multiple times to reformat each level of hyphens (whether there are 2 hyphens, 3, etc.). For example to edit 2 hyphens the {2} at the beginning must be left as a 2, and the {1,2} toward the end must have numbers from 1 up to the number of hyphens which in this case is the number 2.

Break down of the regex. Group 1: matches. . . I was going to describe this more, but I don't think I have time right now

Here's an example Let's say we have a list like this:

Here's some text

-item1 --item2 ---item7 ---item8 item9 item10 --item3 -item1 --item4 --item5 -item6

After find and replace with the regex, the text becomes

Here's some text

-item1 --class item2 { ---item7 ---item8 item9 item10 } --class item3 { } -item1 --class item4 { } --class item5 { } -item6

. . . I was going to describe this more, but I don't think I have time right now