Jump to content

[SOLVED] template engine regex tweak


drifter

Recommended Posts

OK this is from the template engine.

[code]
// matches bracket portion of vars
// [0]
// [foo]
// [$bar]
// [#bar#]
$this->_var_bracket_regexp = '\[[\$|\#]?\w+\#?\]';

// matches $ vars (not objects):
// $foo
// $foo[0]
// $foo[$bar]
// $foo[5][blah]
$this->_dvar_regexp = '\$[a-zA-Z0-9_]{1,}(?:' . $this->_var_bracket_regexp . ')*(?:\.\$?\w+(?:' . $this->_var_bracket_regexp . ')*)*';
[/code]

So I want to tweak the last one so that it will accept $foo + $bar or $foo - $bar[0] or $foo + 4

basically I want to take the same expression and be able to add 0 or more of these expressions to the end  (or integers) with +- operations

I know this should be easy since most of it is there.

Thanks Scott
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.