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

Question about whitespaces #2

Open
Zeta611 opened this issue Jul 25, 2022 · 3 comments
Open

Question about whitespaces #2

Zeta611 opened this issue Jul 25, 2022 · 3 comments

Comments

@Zeta611
Copy link

Zeta611 commented Jul 25, 2022

Is there a way to match against tab or newline characters?

Thanks for the great tool!

@art-w
Copy link
Owner

art-w commented Jul 25, 2022

Hello! The tab characters are replaced by 4 spaces during preprocessing so I'm afraid it's not possible to search for them... which usecase did you have in mind? (you can however search \t for code that uses this escape notation in chars/strings https://sherlocode.com/?q=%5Ct )

For newlines, there is some secret syntax:

You may also enjoy the undocumented syntax \b for "word boundary" : let's say you are searching for the keyword in, but the matches contain wrong stuff like begin or inside... You could try adding spaces around in, but then it wouldn't find )in or in\n. This is where the \b word boundary is useful : it doesn't match a character, but checks that a word starts/ends at this location, so searching \bin\b would only find real appearance of the word "in" https://sherlocode.com/?q=%5Cbin%5Cb

@Zeta611
Copy link
Author

Zeta611 commented Aug 10, 2022

Hi, sorry for the late response.

The use case for matching whitespaces, including newline characters, was for searching patterns that span multiple lines of code. It doesn't seem possible to match patterns using pattern1\$\^pattern2, to match a line ending with pattern1 and starts with pattern2 at the line that follows.

Nonetheless, the word boundary matching \b pattern you mentioned seems to be very useful!

@art-w
Copy link
Owner

art-w commented Aug 11, 2022

Ha right, sorry no it's not currently possible to match on multiple lines (but it would be nice indeed :) )

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

2 participants