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: special case ^ and $ require special treatment #843

Open
lifenjoiner opened this issue Aug 17, 2024 · 3 comments
Open

Regex: special case ^ and $ require special treatment #843

lifenjoiner opened this issue Aug 17, 2024 · 3 comments
Labels

Comments

@lifenjoiner
Copy link
Contributor

a847154

  1. Continuous search after found, requires one extra move;
  2. Select All does not work yet.
@zufuliu zufuliu added this to the Boost regex engine milestone Aug 17, 2024
@zufuliu zufuliu added the regex label Aug 17, 2024
@zufuliu
Copy link
Owner

zufuliu commented Aug 17, 2024

^ and $ seems is working, what's the test case?
image

@lifenjoiner
Copy link
Contributor Author

lifenjoiner commented Aug 17, 2024

Yes, your example works, and the special cases are:

  1. only ^ or $, to quickly select the beginning or ending of lines, especially the ending;
  2. ^ and $, to select empty lines.

"Find All" works, other actions don't.

@zufuliu zufuliu removed this from the Boost regex engine milestone Aug 18, 2024
@zufuliu
Copy link
Owner

zufuliu commented Aug 18, 2024

empty matches are skipped:

notepad4/src/Edit.cpp

Lines 5480 to 5489 in 1060547

if ((findFlag & SCFIND_REGEXP) && iSelCount == 1) {
const char ch = *text;
if (ch == '^' || ch == '$') {
const Sci_Line lineCount = SciCall_GetLineCount();
matchCount = lineCount - (ch == '^');
UpdateStatusBarCache(StatusItem_Find);
UpdateStatusbar();
return;
}
}

notepad4/src/Edit.cpp

Lines 5590 to 5595 in 1060547

const Sci_Position iSelCount = ttf.chrgText.cpMax - iPos;
if (iSelCount == 0) {
// empty regex
cpMin = SciCall_PositionAfter(iPos);
continue;
}

@zufuliu zufuliu changed the title Boost Regex: special case ^ and $ require special treatment Regex: special case ^ and $ require special treatment Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants