In OpenGrok how do you do a full search for special non-alphanumeric characters
Asked Answered
F

2

7

I am trying to search my codebase for code that calls a function named "foo" so I am searching for "foo(" but the results I'm getting includes everything with the word foo in it which includes css, comments and strings that don't even have the trailing open parenthesis.

Anyone know how to do a search for strings that include special characters like ),"'?

Fluidics answered 31/12, 2014 at 2:32 Comment(1)
Check this answer - #21104186Queenie
P
4

When searching for special characters, try using escape character before the character, i.e. \, e.g. "foo\(".

Additionally, I found a reply for a similar question (see http://marc.info/?l=opensolaris-opengrok-discuss&m=115776447032671). It seems that frequently occurring special characters are not indexed because of performance issues, therefore it might not be possible to effectively search for such pattern.

Penman answered 7/7, 2015 at 13:49 Comment(0)
L
2

Opengrok supports escaping special characters that are part of the query syntax. Current special characters are: + - && || ! ( ) { } [ ] ^ " ~ * ? : \ /

To escape these character use the \ before the character. For example to search for (1+1):2 use the query \(1\+1)\:2

Lacework answered 3/10, 2017 at 16:29 Comment(2)
I had a search term that included a hyphen - character, and I needed to enclose it in quotes for the search to work as I expected. e.g. "customer\-content". I'm using OpenGrok version 1.3.6.Inside
I was trying to search for a string "zookeeper:" - so I entered a query as 'zookeeper\:' - and it is still returning results for strings containing just 'zookeeper, without the ':' at the end ...Broadbrim

© 2022 - 2024 — McMap. All rights reserved.