Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3215132
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:08:31+00:00 2026-05-17T15:08:31+00:00

Greetings All, I need to optimize a RegEx I am using to parse template

  • 0

Greetings All,

I need to optimize a RegEx I am using to parse template tags in my CMS. A tag can be either a single tag or a matching pair. An example of some tags:

{static:input:title type="input"}

{static:image:picture}<img src="{$img.src}" width="{$img.width}" height="{$img.height"} />{/static:image:picture}

Here is the RegEx I currently have that properly selects what I need but I ran it through the RegexBuddy debugger and it takes tens of thousands of steps to do one match if the HTML page is quite large.

{static([\w:]*)?\s?(.*?)}(?!"|')(?:((?:(?!{static\1).)*?){/static\1})?

When this matches a tag, Group 1 is the parameters which is all the colon separated words. Group 2 is the parameters. And Group 3 (If it’s a tag pair) is the content between each tag.

I’m also having problems when I stick these tags inside my conditional tags as well. Something like this doesn’t match group 2 properly (Group 2 should be blank in both the matched tags below):

{if "{static:image:image1}"!=""}
    <a href="{static:image:image1}" rel="example_group" title="Image 1"></a></li>
{/if}

Another situation that needs to work is have the same tag being used twice in a row but the first instance being used a single tag and the second being used as a tag pair. So something like this:

{static:image:picture}
{static:image:picture}<img src="{$img.src}" width="{$img.width}" height="{$img.height"} />{/static:image:picture}

There needs to be two separate matches. The first match would have only group 1. The second match would have group 1 and group 3.

If anyone needs more information, please don’t hesitate to ask. The CMS is built in PHP using the CakePHP framework.

Big kudos to anyone who can help me out :D!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:08:32+00:00Added an answer on May 17, 2026 at 3:08 pm

    I’ve come up with a solution that is working very nicely for now. I’m going through and grabbing all the paired tags first and then grabbing the single tags after that. I then use PHP to do the recursive aspect of tags being inside other tags content.

    The suggestion that dogmatic69 came up with might be a more complete fix further down the track.

    Thank you all for your suggestions and possible solutions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings all, I'm trying to localize a .NET/C# project. I'm using string resource files
Greetings, I need a way (either via C# or in a .bat file) to
Greetings all. I need to get some opinions from those outside of my work
greetings all, i have multi sub-domain on my domainname.com , i need to redirect
Greetings all. I have 2 actions: Find and Run. They can be invoked in
Greetings to all! This is my first question here on stackoverflow. I have a
I am new here so first of all my greetings to you I am
Greetings. I'm looking for a way to parse a number of XML files in
Greetings, I'm trying to find either a free .NET library or a command-line executable
Greetings all, I realize this issue has been posed before in other forms, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.