Comments (4)
It's probably specification.
Extend doc about subexpression calls #105
https://github.com/k-takata/Onigmo/pull/105/files
Regex engine "oniguruma" do the same behavior.
from onigmo.
p "ABXY".sub(/(.)\g<1>(.)\g<2>/,'[\1][\2]')
# result: "[B][Y]"
p "ABXY".sub(/(?<q>.)(?<q>.)(?<n>.)(?<n>.)/,'[\k<q>][\k<n>]')
# result: "[B][Y]"
p "ABXY".sub(/(.)\g<2>(.)\g<1>/,'[\1][\2]')
# result: "[Y][X]"
p "ABXY".sub(/(?<q>.)(?<n>.)(?<n>.)(?<q>.)/,'[\k<q>][\k<n>]')
# result: "[Y][X]"
https://github.com/kkos/oniguruma/blob/master/doc/RE
line 410
When backreferencing with a name that is assigned to more than one groups,
the last group with the name is checked first, if not matched then the
previous one with the name, and so on, until there is a match.
from onigmo.
/(.)(\g<1>)/
eq
/(?<m>.)(?<t>(?<m>.))/
MatchData1: \k<m> # ==B
MatchData2: \k<t> # ==B
from onigmo.
Named backrefs behave differently in Perl syntax #74
https://github.com/k-takata/Onigmo/blob/master/sample/simple.c
line:16,17,20 rewrote
Onigmo6.2.0 in ONIG_SYNTAX_PERL
"(.)((?1))\\k<1>"
"ABB"
[result]
match at 0
0: (0-3)
1: (1-2)
2: (1-2)
"(.)((?1))\\g{1}"
"ABB"
[result]
match at 0
0: (0-3)
1: (1-2)
2: (1-2)
"(.)((?1))\\k<1>"
"ABA"
[result] search fail
"(.)((?1))\\g{1}"
"ABA"
[result] search fail
from onigmo.
Related Issues (20)
- invalid pattern compilation /(^*0m\d{2}\:\d{2}\:\d{2})/ HOT 1
- 'st_check_for_sizeof_st_index_t' declared as array with a negative size HOT 15
- Python packaging
- Memory corruption in onig_error_code_to_str() HOT 1
- Out-of-bounds read in parse_char_class() HOT 1
- ſ(U+017F) and K(U+212A) should not be case-insensitive equivalent to S and K HOT 5
- error: Linking globals named 'regerror' with Emscripten
- Memory leaks reported by Scan Coverity
- Stack-buffer-overflow in renumber_by_map in regcomp.c HOT 1
- Name2CType data wrong for many Indic scripts? HOT 2
- `[\p{Emoji}]` also matches numerical characters HOT 1
- Absence operator is broken HOT 2
- Add API to mitigate exponential backtracking (ReDoS) HOT 3
- Use of \K when the string to match after \K can be empty
- Support Unicode script extensions
- An error occurred while using case-insensitive option (?i) . HOT 5
- A deficient regex pattern causes app to freeze .
- Separating or excluding the regcomp/regexec/regerror functions from the library.
- Windows | fatal error C1083: Cannot open include file: 'alloca.h': No such file or directory HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from onigmo.