Caldav Personal Regular Expression

Hi Everyone!

I’m trying to configure a CalDav item to only match a specific RegEx. I confirmed that the actual regex is correct. The doc says:

filter-name:'\<regular expression\>'

How should I enter my Regular Expression?
Just entering filter-name:‘Regular Expression here’ seems to match everything. Entering like filter-name=’\Regular Expression here’ gives an error upon loading.

How should I use regex in the caldav configuration?


After you sure, because REGEX works differently in OH from standard. Your expression must match the full string, even if it’s multiple lines. Only the first group gets returned.

Events in my calendar are not multiline and I think the first group has the value.

But I will try to be more specific, maybe you can help.

The regex I have:


So I want to filter the events which start with ‘szállás’ (or with an uppercase - I know that there are flags also for this, but I don’t know if it works in OH or not) or has the word ‘Hotel’ in the event name.

It gives a ‘Full match’ for me on a regex tester like this:

Or maybe I just need to add braces for this regex like this:


This is what I haven’t tried yet. This way it also returns the 1st Group in every Regex tester.

Like I said, the regular expression must match the full string. That regular expression will only match one word. I doubt your calendar entry is just one word so you need to have the regular expression match everything after that first word too.

As per my understanding and tests you should try it with the following regex:


Maybe the ^ at the beginning can be removed too. Didn’t test that.

Thanks I came up with something similar, I will test!

Thank you!

Tried it like this:

Switch  GoogleVacation          "Google Vacation"                                   (gCal)              { caldavPersonal="calendar:google type:PRESENCE filter-name:'[Ss]zállás.*|.*[Hh]otel.*'" }

However still, all my events are returned here. Tried creating a group, etc… Doesn’t help.

Have you tried putting the binding into TRACE mode and checking the log output?

That’s the first thing you should’ve done.

Totally right, I forgot. I will try and see if that helps anyhow…

@rkrisi, did you ever get this working? I just had a go with some Items and figured out a few… nuances of this binding. The binding is using regex to extract the regex for the filter-name. When you use anything other than what is in the allowed character set, the matching stops. Your filter expression cannot contain anything other than A-Z, a-z, ., *, +, -, |, and spaces. You are using special characters, which will stop the matching. Character sets will also stop the matching due to the [. If the matching stops before the end, nothing will be found. However, if the matching stops at the very beginning, like when ^ is used, then there is effectively no filter and everything is returned. Hopefully some of this makes sense! The documentation definitely needs an update.

I suggest you try this…


Hopefully, the new binding will make this easier to use (@damihe, @AndrewFG) :slightly_smiling_face:!

Thanks @5iver!
No I was not able to solve it yet, but I will try with your example!


1 Like

That seems like a bug to me. I did a brief scan and couldn’t find a reason why that restriction should exist.

I was hoping you’d take an interest in this one :slightly_smiling_face:. The binding uses…

private static final String REGEX_FILTER_NAME = "filter-name:'?([A-Za-z\\.\\*\\+\\- \\|]+)'?";

… as its regex, which excludes everything else. As a minimum, I’d add [, ], ?, ^, :, 0-9, and $. I could do a PR, but time is tight. It’s simple though…

private static final String REGEX_FILTER_NAME = "filter-name:'?([!@%&#:0-9A-Za-z\\.\\*\\+\\- \\|\\?\\[\\]\\^\\$]+)'?";

Although, I wonder why characters are being whitelisted instead of blacklisted. Or, why not allow everything?

private static final String REGEX_FILTER_NAME = "filter-name:'(.*)'";

I agree with allowing all characters.

1 Like

Here’s the PR…

1 Like