Giter Site home page Giter Site logo

Comments (4)

tonco-miyazawa avatar tonco-miyazawa commented on September 22, 2024

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.

tonco-miyazawa avatar tonco-miyazawa commented on September 22, 2024
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.

tonco-miyazawa avatar tonco-miyazawa commented on September 22, 2024

/(.)(\g<1>)/
eq
/(?<m>.)(?<t>(?<m>.))/

MatchData1: \k<m>    # ==B
MatchData2: \k<t>    # ==B

from onigmo.

tonco-miyazawa avatar tonco-miyazawa commented on September 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.