ok so i know how to write a reg expression for something more specific but i dont know how to make it more dynamic.

right now i am matching {tour:right} with this {tour:([A-Za-z0-9_]+)}

But the question is how do i write it so that i can use {tour} and {tour:right} interchangeably. the idea is that there will be a default of left set on the item in the code. but if they need to change it to right they have to use :right.

This should be simple i hope but i have not learned how to write regs like that yet. if it is possible. If not then ill just have to right our more code.

Thanks in advance

{tour([:]\w+)?}

Thanks.

So why is it so much different from what i originally had?

'+' means one or more match at least one match whether '?' means zero or one.

I am making everything in the parenthesis optional - including the colon. You on the other hand were making the colon required. Also, \w is shorthand for all the characters that you have within the bracket.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.