Expand my Community achievements bar.

SOLVED

How can I search for user names that contain a non-alphanumeric

Avatar

Level 3

I would like to search for any users under home/users with a first or last name that contain a non-alphanumeric character. I've tried the following SQL2 but no luck:

 

SELECT * FROM [rep:User] AS user WHERE ISDESCENDANTNODE([/home/users]) AND [profile/familyName] is not null AND [profile/familyName] LIKE '%[^a-zA-Z0-9]%' AND [profile/givenName] is not null ORDER BY [profile/familyName]

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @stiegjo, JCR query is not supporting regular expression. Some operators supports wild cards e.g.

  • LIKE supports: % and _
  • CONTAINS supports: * and OR

In your case I would simply use query to get all users and as a next step do the filtering on Java level.

You can also try to build a query that will check if specific (unwanted/special) char is included in givenName or familyName - so the other way around comparing to your current strategy. But I can image that this kind of query could be complex and maybe it will not give you the expected result.

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi @stiegjo, JCR query is not supporting regular expression. Some operators supports wild cards e.g.

  • LIKE supports: % and _
  • CONTAINS supports: * and OR

In your case I would simply use query to get all users and as a next step do the filtering on Java level.

You can also try to build a query that will check if specific (unwanted/special) char is included in givenName or familyName - so the other way around comparing to your current strategy. But I can image that this kind of query could be complex and maybe it will not give you the expected result.