How to Search String with Special Characters, e.g. "&"?

Post Reply
xiaoqi
Posts: 143
Joined: 09 Feb 2023, 03:33

Hello,

I've introduced to colleagues of using the Search feature to get in-scope classes which it's quite convenient.

However, today, I found one issue when I have some special characters in the Searching string, the special character is removed during search querying, hence the expected result is not coming. Below are some sample:

Want to search "Credit & Risk", it returns result for "Credit Risk", the "&" is ignored.
Want to search "Credit ? Risk", it returns result for "Credit Risk" as well, the "?" is ignored.
Want to search "(Special Treatment)", it returns result for "Special Treatment", both "(" and ")" are ignored.

Checking file "common/core_search_results.xsl", I found two lines may relevant:

Code: Select all

LINE 34: <xsl:variable name="currentSearch" select="replace(replace($SearchQuery, '[^\c]', ' '), ':', '')"/>
LINE 37: <xsl:variable name="matchingInstances" select="$allValues[matches(., $currentSearch, 'i')]/../.."/>
I so there's certain Regex filtering rule set here, but I don't quite familiar with Regex yet.

May I get your help to know how I can include certain special charaters in the searching? For "&", we use this quite often in element names.

Thanks greatly,
Xiaoqi
User avatar
neil.walsh
Posts: 454
Joined: 16 Feb 2009, 13:45
Contact:

Hi,

This is not possible with the current implementation of the Viewer search functionality. The search query is passed as a URL parameter and is escaped. This removes anything that is not a "character" (e.g., a letter or number in this case).

It's a fairly basic search right now and it is working as intended. We plan to offer a more full featured search in the future and while that's on our roadmap, it's not our current focus.

I'll pass on your interest to the team

Best,

Neil
xiaoqi
Posts: 143
Joined: 09 Feb 2023, 03:33

Thanks a lot Neil, now understand this restriction and will communicate with people who are using the search bar.

Yes, it's really needed, given the reason that we have lots of "name" may at list have "&".

Thanks a lot,
Xiaoqi
Post Reply