Forum:DPL escaping single quote in regex.....

Argh...been bending my head the previous 3 hrs over the next problem.....any help is appreciated! ;)

I use DPL to get my data from a different page. In the DPL query I use the includematch parameter. What I want is that it checks if variable item#1 matches the pagename (i use it as a template) If it does, it should include the result.

So my parameter is set like: includematch=/\|\s*item#1\s*=\s*/s

This works very well. HOWEVER there are two problems... First off al the match isn't an exact match. If I have an item called "ball" and also an item called "baseball" if I query on ball I end up with "ball" and "baseball". I want it to be exact....I guess the \s* say it can hold spaces or something...

The second thing, which is more annoying is that i have items called "Patrick's Ball" For this it doesn't work. I guess it is the single quote. So I should escape it!

If I hardcode: includematch=/\|\s*item#1\s*=\s*Patrick\'s Ball/s It works well for "Patrick's Ball" but i would want to keep it generic ofcourse.

So i've build a template that replaces the ' with a \' I couldn't get it to work with the simple:

So I've used the much overheaded:

This eventually resolves in "Patrick\'s Ball" However if I put that in the part of the inculdematch parameter it doesn't work.

So can anyone help me out here? I've also used templates to include and escaped the | obviously...but it still doesn't work...

Rothmans 23:13, September 1, 2011 (UTC)