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

Regex find does not match on beginning and end of lines (missing multiline flag?) #11572

Closed
erikbra opened this issue Sep 6, 2016 · 6 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-find Editor find operations verified Verification succeeded

Comments

@erikbra
Copy link

erikbra commented Sep 6, 2016

  • VSCode Version: 1.4.0
  • OS Version: Windows

Steps to Reproduce:

  1. Search for regex including beginning or end of line matches. Examples:
    • ^\s*$\n (should match empty lines)
    • ^A.*B$ (should match every line starting with A and ending with B (e.g. A****************B)
  2. Expected: match
  3. Actual: No match.

Ref. issue #313, which is closed, but in essense the same, or at least very similar.

Esp. @alexandrudima 's comment, stating that this might be to a missing multiline flag passed to the Javascript regex engine.

#313 (comment)

@sandy081 sandy081 added editor-find Editor find operations editor bug Issue identified by VS Code Team member as probable bug labels Sep 6, 2016
@sandy081 sandy081 added this to the September 2016 milestone Sep 6, 2016
@sandy081 sandy081 self-assigned this Sep 6, 2016
@jrieken jrieken added the verified Verification succeeded label Sep 29, 2016
@erikbra
Copy link
Author

erikbra commented Oct 7, 2016

This does not work as expected in September (insiders build).

^\s*$\n matches on end-of-every-line. Should only match empty lines. It says:

^ - start of line
\s* - none or more whitespaces
$ - end of line
\n - newline

^\s*$\n matches empty lines in all other regex editors (sublime, Visual studio, regex testers)
^\s+$\n matches empty lines.

It looks as if ^\s*$\n starts matching on the previous line (I can tell from looking at the highlights). So it's not respecting the ^. See also #11575.

@sandy081
Copy link
Member

sandy081 commented Oct 7, 2016

@erikbra Thanks for reporting.. I will investigate this empty lines case.

@sandy081
Copy link
Member

sandy081 commented Oct 7, 2016

@erikbra You can use regex ^\s*$ also to match empty lines.

Filed #13355 for this particular case.

@erikbra
Copy link
Author

erikbra commented Oct 10, 2016

Hi.

Thanks for looking into this.

^\s*$ does not do the trick. Instead of doing what I want. It only matches on the first occurence of empty lines. I don't really understand why, but that's what it does.

^\s*$\n does not seem to
respect the ^, as it seems to treat the newline on the previous line as part of the next line (see attached screenshot).

I have attached screenshots from another editor (Sublime, but this is common on all other regex-aware editors) which demonstrates the difference.

Test text used:

søflkjasdlkfj

           asdølfnasdøfln   
dasfsadf

asdfasdfasdf


gasgasdgasdgasd

newline-matches-non-empty-lines-also

no-newline-matches-only-first

sublime-newline-matches-only-blank-lines-and-does-not-remove-initial-empties-on-next-line

sublime-no-newline-matches-also-blanks-in-next-line

@erikbra
Copy link
Author

erikbra commented Oct 10, 2016

Maybe this is the problem? Looks like you do some sort of single/multi-line optimization on regexes? #9051 (comment)

@sandy081
Copy link
Member

@erikbra I will have to check and confirm you. Thanks.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug editor-find Editor find operations verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

3 participants