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

Whole Word #379

Open
paulobuchsbaum opened this issue Apr 6, 2022 · 2 comments
Open

Whole Word #379

paulobuchsbaum opened this issue Apr 6, 2022 · 2 comments

Comments

@paulobuchsbaum
Copy link

paulobuchsbaum commented Apr 6, 2022

Great tool because, standard search tool in Chrome (the most used browser by far) sucks. It's just a very basic search.

So it would be immensely useful for almost all users if this tool (Find + Regex) had the whole word option (similar to Office and other tools)

I know that it would be possibile to reproduce it using regular expression:

     (?:^|[-\s\(){}[\]/\\|<>=])+(item)(?=$|[\s\-(){}[\]/\\|<>=])

Where one need to replace the item with the desired word.

I like this regex because it extends the word concept and considers (, ), {, }, [, ], |, , /, <, >, = and – as word separators. This approach includes numbers (in many formats) within the whole word concept and and additionally fits many foreign languages.

However, using regex to simulate whole word is very clumsy.

@brandon1024
Copy link
Owner

This extension only supports regular expressions that are supported by the Javascript language. Building a custom regex engine isn't exactly something I want to build and support in the long term.

@mrienstra
Copy link

@paulobuchsbaum, it sounds like you want something like VS Code's "Match Whole Word" find option, which essentially just wraps your search with \b (though it first checks to see if it's needed or not on each end), see microsoft/vscode src/vs/base/common/strings.ts#L182-L189.

VS Code also has EditorOption.wordSeparators for "[c]haracters that will be used as word separators when doing word related navigations or operations." (source):

`~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?

... But I don't believe that's used for finding/searching, but rather for selecting / navigating / etc.


If I'm understanding you correctly, as to your suggestion:

Similar functionality could be added, I do find it convenient occasionally to use VS Code's "Match Whole Word" find option, though more often I just manually add \b as desired, since I usually leave "Use Regular Expression" on, and when I toggle other less-used options on ("Match Whole Word", "Match Case"), I sometimes forget that I've done so and waste time being confused as to why I can't find something.

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

No branches or pull requests

3 participants