Giter Site home page Giter Site logo

Comments (4)

Arithmeticus avatar Arithmeticus commented on July 18, 2024 1

This reminds me that I have sometimes wished that we had named groups, which serves a kind of commentary function. But the angle brackets used in C# regexes wouldn't be copacetic, and the colons might be just the right substitute. XSLT's regex-group could then be adjusted to allow integers or strings.

At any rate, comments and named groups would make regular expressions more declarative, and therefore more QT-like.

from qtspecs.

liamquin avatar liamquin commented on July 18, 2024

Thanks, it’s possible named captures could be made available through a map. Perl uses $+{name} to refer to them in the substitution part, and also offers (?'NAME'pattern) which might work.

A thing to watch for with named groups is that in some systems (e.g. .NET) the named groups are not included in the numbering, and in others (including Perl) they are.

We can't use Perl's syntax for comments, because it's line based, and newlines in select attributes go away under attribute value normalization during parsing (or become spaces).

from qtspecs.

michaelhkay avatar michaelhkay commented on July 18, 2024

The Perl syntax for comments ('#' up to newline) is clearly troublesome given XML attribute value normalization which kills newlines.

Coming up with any other syntax is difficult because anything we do might clash with some existing convention or prevent us adopting some regex feature that we're not currently aware of.

Perhaps we could do something along the lines of "literate regular expressions" - see https://hackaday.com/2020/09/11/linux-fu-literate-regular-expressions/

Or just encourage people towards invisible XML.

from qtspecs.

michaelhkay avatar michaelhkay commented on July 18, 2024

I suggest that we allow comments if the flag '#' is present, and that comments start with '#' and end with '#' or the end of the regex string. I don't think we can overload flag x to allow both comments and whitespace for backwards compatibility reasons. A '#' can be escaped by writing \# or [#].

I'd suggest treating named capturing groups as a separate issue.

from qtspecs.

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.