Regex to select the end of template


Well-known member
I need to paste my code right where the template ends. I am at odds with regex so I am asking you to help me with this. Hope this will also help other people who want to include their code with TM.


Well-known member
Well I haven't played with the TM yet but if I assume correct, to literally add content to the end of a template regardless what is already in the template you would need to just capture all text and then replace that with all of that captured text + what ever you are adding.

If I am correct in thinking this will work...

in the expression
#.+#siu will literally capture everything

in the replace
$0 will put all that captured text back and then you can enter your data after that


.content2 {

I need to play around with it still. Please let me know if that works for you


Well-known member
Nope, still no luck with this. Fun thing that even none of the regex works with filled templates. I tried @Mike's code and it doesn't work too.

Maybe there is a bug in beta 3.


Well-known member
This works inserting at the end of a template if there is content...and also will insert into a blank template


I think you should use that...*if you add content to the template later I think it will add your replacement multiple times with just ^\s*$ (oddly I was testing the same regex and didn't check the link until after I tested this)

*EDIT: I take that back , ^\s*$ alone will not add content if the extra.css is not blank which means if a person is using a style relying on this and adds content to the template the TM will not apply anymore
Last edited: