[Solved] Help with regular expression and id_hierarchy from content db table
Posted: Wed Aug 05, 2009 7:56 pm
Hi there,
within the plugin content_dump, I have a mysql query with a regular expression to find pages belonging to a content branch (e.g. page id 50).
The problem, this also matches page IDs like 505, 150 or other hierarchy ID strings containing '50'
Of course, as long as I do not have as many pages or the other parameters prevent the plug-in from coming across any other page IDs containing '50', the problem will never arise. It's obvious now that I know it, but it never surfaced previously.
RegExp is not my best subject. I tried some things, but I just can not foprmulate what I have to do.
It needs to be like: if it contains '50' and '50' has a preceding '.' or nothing and is followed by a '.' or nothing. So it would match e.g. "50.60.70" or "60.50.70" or "60.70.50" but not "505.20.30" or "120.150.60".
I tried:
But this matches if there is none or more '.' - so '550.412.120' would also match for '50'.
Using:
Matched if there is at least one '.' - but this is not the case if the ID is in the first or last position.
I'm blocked at the moment. Does anyone have a hint what I could do? Any help is much appreciated.
Best
nhaack
within the plugin content_dump, I have a mysql query with a regular expression to find pages belonging to a content branch (e.g. page id 50).
Code: Select all
SELECT
XYZ
FROM
cms_content
WHERE
XYZ
AND
id_hierarchy REGEXP '50'
Of course, as long as I do not have as many pages or the other parameters prevent the plug-in from coming across any other page IDs containing '50', the problem will never arise. It's obvious now that I know it, but it never surfaced previously.
RegExp is not my best subject. I tried some things, but I just can not foprmulate what I have to do.
It needs to be like: if it contains '50' and '50' has a preceding '.' or nothing and is followed by a '.' or nothing. So it would match e.g. "50.60.70" or "60.50.70" or "60.70.50" but not "505.20.30" or "120.150.60".
I tried:
Code: Select all
[\.]*50[\.]*
Using:
Code: Select all
[\.]+50[\.]+
I'm blocked at the moment. Does anyone have a hint what I could do? Any help is much appreciated.
Best
nhaack