Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a 'use string literally' search option #186

Closed
Wilfred opened this issue Jan 22, 2016 · 4 comments · Fixed by #397
Closed

Add a 'use string literally' search option #186

Wilfred opened this issue Jan 22, 2016 · 4 comments · Fixed by #397

Comments

@Wilfred
Copy link
Contributor

Wilfred commented Jan 22, 2016

Sometimes I want to search for some code that contains regexp metacharacters, e.g. I want to search foo.baz[bar](). It would be nice to have an option in the UI to do this -- I find it takes some thought to work out it's foo\.baz\[bar\]\(\).

@dgryski
Copy link

dgryski commented Jan 22, 2016

Probably straight forward to add a "quotemeta" option and pass the query to https://golang.org/pkg/regexp/#QuoteMeta if present.

@electrofelix
Copy link

Use case: Cutting and pasting part or all of a line of code to search for it seems like a common operation, and since code frequently will contain characters that are special in regex terms, currently I find I need to edit the line after pasting instead of just cut/paste/search. The number of times I need to do a regex search for code has been relatively low, but an additional click or key press on top of typing in a regex for code seems like a very small increase in input for that use case compared to the cut/paste/search.

I think it would be useful to be able to make this the default through the UI, with the option to switch the search to regexp/plain depending on the site default, and leave it up to site admins to determine based on usage which is most useful default for their users.

@StingyJack
Copy link
Contributor

The number of times I need to do a regex search for code has been relatively low..

For me its so low its almost never. The only time I think I've ever tried a regex for code searching was trying to count LOC using Visual Studio's find tool (it didnt work anyway).

I'm searching code to find usages, so I already know the identifier. Literal should be the default.

@NightMachinery
Copy link

It would also be much more intuitive if whitespace was treated as AND ala fzf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants