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)


 * For the first issue, you might want to try a workaround like this: . But this might not also cover all possibilities. Read up on Perl Regular Expressions to learn more.


 * As for the second issue. I'm not sure which DPL syntax are you using:,  or  , but you might want to experiment with all of them, since, if I recall correctly, only the parser function invocation will accept string/parser functions as parameters. To be of more help I would need links to the pages in question. — Sovq 07:06, September 2, 2011 (UTC)