• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Regex to select the end of template

CyberAP

Well-known member
#1
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.
 

EQnoble

Well-known member
#4
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

example
$0

.content2 {
height:420px;
}

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

CyberAP

Well-known member
#7
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.
 

EQnoble

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


#(.+|^\s*$)#siu

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: