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 ),"'?

DiverseAndRemote.com
  • 19,314
  • 10
  • 61
  • 70
  • Check this answer - https://stackoverflow.com/questions/21103686/is-it-possible-to-search-for-a-phrase-in-opengrok-containing-curly-brackets/71204553#71204553 – Adir Dayan Feb 21 '22 at 10:19

2 Answers2

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.

Quarra
  • 2,527
  • 1
  • 19
  • 27
1

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

melfors
  • 11
  • 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. – Adam Porad Jan 10 '20 at 18:43
  • 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 ... – Marina Feb 24 '20 at 17:39