5003Re: [Cheetahtemplate-discuss] Test string against expression?
- Sep 17, 2012If you're coming from Perl, the first thing you should know about python is that regular expressions are generally the Wrong Way to do it.Nearly everywhere you'd use a regex in perl, you use a string method in python. It's more explicit and faster (especially since regex in python is not super optimized like perl).
On Mon, Sep 17, 2012 at 11:22 AM, Rick Miller <vmiller@...> wrote:On Mon, Sep 17, 2012 at 2:04 PM, Buck Golemon <buck@...> wrote:Thanks, Buck! I'll check out that tutorial!
> Cheetah is a superset of python (kindof).
> Get your logic working in python, then port it to cheetah.
> You want re.match, from the standard python library:
> In your particular example below however, regular expressions are overkill,
> just use the string `in` operator:
> #if 'string' in $getVar('name')
> #set foo = "bar"
> #set bar = "foo"
> #end if
> That's basic python. You should take a couple hours and run through the
> official tutorial.
> At *least* skim the parts on string processing.
- << Previous post in topic