Search

I have a section that has entries beginning with “New article posted.” I can easily extract only those entries with a DS that filters on regexp:^New article posted. But what I want to do is extract all but those entries. I’ve spent several hours researching how to do this but have failed. I found plenty of ways to exclude the unwanted entries but they also exclude entries that I want to include.

At first I couldn’t believe that regex doesn’t include a simple way to negate the above expression, but then I realized why it doesn’t. It’s a lot more straight-forward to just negate the outcome of a regex search. In mysql this is done by placing NOT before REGEXP. But the DS editor doesn’t provide for that. Is it possible to have it added. I looked at the code and found that it wouldn’t be difficult, but every field class would have to be changed.

(Now watch someone step up and show me a very simple way to do what I want without the NOT option. Actually I would like that.)

If it’s really just one article you don’t want to display (and no other stuff like pagination involved) I’d suggest you filtered them in your XSLT.

Hmm I thought you may be able to do this using negation in regex but I couldn’t quite get this working in http://regexpal.com. That said, running a negation example that I know works through regexpal also fails, so maybe the following is actually correct and I am just checking it the wrong way.

^(?:(?!New\sarticle\sposted))$

It does involve multiple entries. I’m currently filtering in my XSLT and it does screw up the pagination.

I’m pressing ahead with a modification for the textarea field only (field.textarea.php). I’m adding a new flag notregexp: to the DS filter field that will translate to NOT REGEXP in the mysql query.

I’ll give that a try Nick, but without the ending $. There is additional text after “New article posted.”

I couldn’t get your expression to work Nick, even with the ending $. It excludes all entries.

Maybe MySQL regex work slightly differently. It sounds like your “New article posted” entries are some kind of meta or notification, rather than a true article? Could you not use a checkbox in the section to indicate that these are an entry of specific type.

@wisolman I think the NOT REGEXP solution you suggested is the best answer!

EDIT: Although that would be a customisation.

Just been reading… MySQL REGEXP and RLIKE do not support ? in expressions, hence the need for NOT REGEXP and NOT RLIKE

Take a look at answer 3 in this thread, it may be a long way round, but it seems to be a solution. All you would need to do is reverse your logic in your expression to look for the opposite of what you want… If that makes sense.

I have had about the same problem in the past.

To fix it, I have just copied the parent class, made changes (added NOT), saved in another location and included that.

It is the hard way around, and I would really love symphony to support negation logic from the core.

I’m sure they are doing negation in v3 maybe we could request it for the 2.2 release, it can’t be too difficult an addition. Otherwise were going to have to rely on long complicated expressions…

It is the hard way around, and I would really love symphony to support negation logic from the core.

Yep v3 does have this. To add negation regex to v2 it’ll need another if condition added to all of the core field types that support regex (input, select, textarea etc.). Extensions may also need to be updated, so this could create some disparity (and potential confusion) between updated core fields that do support NOT REGEXP and older extensions that do not.

@nickdunn - Yes, the checkbox solution would work but I’ve decided to go with the notregexp: solutioin instead, even though it involves a customization of core files.

@designermonkey - The solution in your link might work but the regex expression would be very long in my case.

@creativedutchmen - I think we should consider having the NOT option apply to all filtering, not just regexp. Just add a checkbox that when checked would negate the defined search.

I looked at v3 and it does have a lot more options for DS filtering, but it’s not obvious to me that it offers negation of REGEXP filtering. It does have “does not contain” and IN BOOLEAN MODE filtering. For my current need the “does not contain” will suffice. Bring on v3.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details