Git Product home page Git Product logo

Comments (5)

hg42 avatar hg42 commented on August 16, 2024 1

yes, named groups count => x=1 y=3.

you can also use [null, 1, "year", 3, "month", "day"], then you simply loop through the array and store names[i]: originalMatch[i] in matches.groups, So, matches.groups["3"] would result in "y".

from regexp-tree.

hg42 avatar hg42 commented on August 16, 2024

that's 1/3 of what I currently do with regexp-tree.

Your example has only named groups. You can also have unnamed groups.
You need to collect an array of both group names and indexes of regular capturing groups (set name = index).

from regexp-tree.

DmitrySoshnikov avatar DmitrySoshnikov commented on August 16, 2024

@hg42, good point, yeah, the second parameter should be map from group name to the index. I think unnamed groups share the same index? I.e. this matches aaa:

/(?<foo>a)\1\k<foo>/

So perhaps:

/(x)(?<year>\d{4})-(y)(?<month>\d{2})-(?<day>\d{2})/

Would give:

new RegExpTree(/(x)(\d{4})-(y)(\d{2})-(\d{2})/, {year: 2, month: 4, day: 5});

from regexp-tree.

DmitrySoshnikov avatar DmitrySoshnikov commented on August 16, 2024

Transform part is done in f1233b9 and 7fb4b34.

from regexp-tree.

DmitrySoshnikov avatar DmitrySoshnikov commented on August 16, 2024

Local runtime support has been added in 0e6a9ff.

from regexp-tree.

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.