x
 
Create New Page
 View Previous Changes    ( Last updated by tbritton )

RegEx to Strip GoLive 6 Dynamic Content

Category:Regular Expressions
Category:RegEx
Category:GoLive
Category:Converting Sites
Category:HowTo

Not to knock the awesome search and replace power native to EE’s control panel (Utilities/Find and Replace), but I am now a Regular Expressions nut, and Dreamweaver, e-texteditor and others allow you to use Regular Expressions (or RegEx) in search queries. And programs like Dreamweaver allow you to apply these RegEx search queries in their Find and Replace tool across multiple selected pages, an entire folder or even an entire site! This article focuses upon removing old dynamic content GoLive PHP tags (almost) entirely from a page in preparation for converting into a regular form page (perhaps for submission into a Form Tools or Solspace Freeform version).

[You can find a great video tutorial and cheat-sheet for Regular Expressions at the e-texteditor.com website.]

For instance, if I want to strip all the old PHP out of a page, two of these alone pull just about everything.

\(\<\?php.*?\?\>\

Will pull all inside parentheses, including the parentheses (do first)( *? makes “not greedy”)

\<\?php.*?\?\

Will pull all the rest (both used in removing old GoLive 6 dynamic content tags from a site, for example).

Or find both using the either/or vertical pipe character |

\<\?php.*?\?\>|\(\<\?php.*?\?\>\

You could pare this down even further simply by making the search for the Parentheses “non-greedy” by adding the question mark afterwards (this does exactly the same as the combination above):

\(?\<\?php.*?\?\>\)? 

—————————————————————————————————
To pull old GoLive 6 <agl:container> opening and closing tags:

\<agl\:container\
\<\/agl\:container\

Or find both using the either/or | pipe:

\<agl\:container\>|\<\/agl\:container\

—————————————————————————————————
To pull just about everything GoLive 6 off of a page, then, you could use this super RegEx that also uses /s*? to un-greedily remove unsightly white spaces around the PHP tags:

\<agl\:container\>|\<\/agl\:container\>|\s*?\(?\<\?php.*?\?\>\)?\s*? 

(This recently saved me from making 7,165 manual edits to an extensive set of 7 forms that were being converted over to instead use Form Tools, as GL6 dynamic content stuff broke with PHP5, it seems.)

So, another great reason to use templates and an external editor having Regular Expressions capabilities!

Terry Leigh Britton

Category:EE1
Category:EE2