Fix RegEx look behind operations and \A and and \b and \z
Fix #713, fix #1870, fix #2216, fix #2360, fix #9004, fix #4855, close #8926, close #9008
This commit is contained in:
parent
d62221fd7f
commit
08190bbe96
@ -16,13 +16,13 @@
|
|||||||
commentExpr="(?s:'''.*?''')|(?m-s:#.*?$)"
|
commentExpr="(?s:'''.*?''')|(?m-s:#.*?$)"
|
||||||
>
|
>
|
||||||
<classRange
|
<classRange
|
||||||
mainExpr ="(?<=^class\x20).*?(?=\n\S|\Z)"
|
mainExpr ="^class\x20\K.*?(?=\n\S|\Z)"
|
||||||
>
|
>
|
||||||
<className>
|
<className>
|
||||||
<nameExpr expr="\w+(?=\s*[\(|:])" />
|
<nameExpr expr="\w+(?=\s*[\(|:])" />
|
||||||
</className>
|
</className>
|
||||||
<function
|
<function
|
||||||
mainExpr="(?<=\sdef\x20).+?(?=:)"
|
mainExpr="\sdef\x20\K.+?(?=:)"
|
||||||
>
|
>
|
||||||
<functionName>
|
<functionName>
|
||||||
<funcNameExpr expr=".*" />
|
<funcNameExpr expr=".*" />
|
||||||
@ -30,7 +30,7 @@
|
|||||||
</function>
|
</function>
|
||||||
</classRange>
|
</classRange>
|
||||||
<function
|
<function
|
||||||
mainExpr="(?<=\sdef\x20).+?(?=:)"
|
mainExpr="\sdef\x20\K.+?(?=:)"
|
||||||
>
|
>
|
||||||
<functionName>
|
<functionName>
|
||||||
<nameExpr expr=".*" />
|
<nameExpr expr=".*" />
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
>
|
>
|
||||||
<!-- within a class-->
|
<!-- within a class-->
|
||||||
<classRange
|
<classRange
|
||||||
mainExpr ="(?<=^class\x20).*?(?=\n\S|\Z)"
|
mainExpr ="^class\x20\K.*?(?=\n\S|\Z)"
|
||||||
>
|
>
|
||||||
<className>
|
<className>
|
||||||
<nameExpr expr="\w+" />
|
<nameExpr expr="\w+" />
|
||||||
@ -25,7 +25,7 @@
|
|||||||
mainExpr="^\s*def\s+\w+"
|
mainExpr="^\s*def\s+\w+"
|
||||||
>
|
>
|
||||||
<functionName>
|
<functionName>
|
||||||
<funcNameExpr expr="(?<=def\s)\w+" />
|
<funcNameExpr expr="def\s\K\w+" />
|
||||||
</functionName>
|
</functionName>
|
||||||
</function>
|
</function>
|
||||||
</classRange>
|
</classRange>
|
||||||
@ -34,7 +34,7 @@
|
|||||||
mainExpr="^\s*def\s+\w+"
|
mainExpr="^\s*def\s+\w+"
|
||||||
>
|
>
|
||||||
<functionName>
|
<functionName>
|
||||||
<nameExpr expr="(?<=def\s)\w+" />
|
<nameExpr expr="def\s\K\w+" />
|
||||||
</functionName>
|
</functionName>
|
||||||
</function>
|
</function>
|
||||||
</parser>
|
</parser>
|
||||||
|
@ -288,13 +288,8 @@ Sci::Position BoostRegexSearch::FindText(Document* doc, Sci::Position startPosit
|
|||||||
regex_constants::ECMAScript
|
regex_constants::ECMAScript
|
||||||
| (caseSensitive ? 0 : regex_constants::icase);
|
| (caseSensitive ? 0 : regex_constants::icase);
|
||||||
search._regexString = regexString;
|
search._regexString = regexString;
|
||||||
|
|
||||||
const bool starts_at_line_start = search.isLineStart(search._startPosition);
|
|
||||||
const bool ends_at_line_end = search.isLineEnd(search._endPosition);
|
|
||||||
search._boostRegexFlags =
|
search._boostRegexFlags =
|
||||||
(starts_at_line_start ? regex_constants::match_default : regex_constants::match_not_bol)
|
((sciSearchFlags & SCFIND_REGEXP_DOTMATCHESNL) ? regex_constants::match_default : regex_constants::match_not_dot_newline);
|
||||||
| (ends_at_line_end ? regex_constants::match_default : regex_constants::match_not_eol)
|
|
||||||
| ((sciSearchFlags & SCFIND_REGEXP_DOTMATCHESNL) ? regex_constants::match_default : regex_constants::match_not_dot_newline);
|
|
||||||
|
|
||||||
const int empty_match_style = sciSearchFlags & SCFIND_REGEXP_EMPTYMATCH_MASK;
|
const int empty_match_style = sciSearchFlags & SCFIND_REGEXP_EMPTYMATCH_MASK;
|
||||||
const int allow_empty_at_start = sciSearchFlags & SCFIND_REGEXP_EMPTYMATCH_ALLOWATSTART;
|
const int allow_empty_at_start = sciSearchFlags & SCFIND_REGEXP_EMPTYMATCH_ALLOWATSTART;
|
||||||
@ -344,15 +339,13 @@ template <class CharT, class CharacterIterator>
|
|||||||
BoostRegexSearch::Match BoostRegexSearch::EncodingDependent<CharT, CharacterIterator>::FindTextForward(SearchParameters& search)
|
BoostRegexSearch::Match BoostRegexSearch::EncodingDependent<CharT, CharacterIterator>::FindTextForward(SearchParameters& search)
|
||||||
{
|
{
|
||||||
CharacterIterator endIterator(search._document, search._endPosition, search._endPosition);
|
CharacterIterator endIterator(search._document, search._endPosition, search._endPosition);
|
||||||
|
CharacterIterator baseIterator(search._document, 0, search._endPosition);
|
||||||
Sci::Position next_search_from_position = search._startPosition;
|
Sci::Position next_search_from_position = search._startPosition;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
bool match_is_valid = false;
|
bool match_is_valid = false;
|
||||||
do {
|
do {
|
||||||
search._boostRegexFlags = search.isLineStart(next_search_from_position)
|
|
||||||
? search._boostRegexFlags & ~regex_constants::match_not_bol
|
|
||||||
: search._boostRegexFlags | regex_constants::match_not_bol;
|
|
||||||
const bool end_reached = next_search_from_position > search._endPosition;
|
const bool end_reached = next_search_from_position > search._endPosition;
|
||||||
found = !end_reached && boost::regex_search(CharacterIterator(search._document, next_search_from_position, search._endPosition), endIterator, _match, _regex, search._boostRegexFlags);
|
found = !end_reached && boost::regex_search(CharacterIterator(search._document, next_search_from_position, search._endPosition), endIterator, _match, _regex, search._boostRegexFlags, baseIterator);
|
||||||
if (found) {
|
if (found) {
|
||||||
const Sci::Position position = _match[0].first.pos();
|
const Sci::Position position = _match[0].first.pos();
|
||||||
const Sci::Position length = _match[0].second.pos() - position;
|
const Sci::Position length = _match[0].second.pos() - position;
|
||||||
|
Loading…
Reference in New Issue
Block a user