Git Product home page Git Product logo

Comments (3)

kkos avatar kkos commented on August 27, 2024 1

I don't even know if it supports nested repeat operators in the first place, so I'll refrain from writing a PR.
But if you want to match the Python result, you would have something like this:

  { OK,  "a?",                        "",                 (char*) 0      },
  { OK,  "a?",                        "a",                (char*) 0      },
  { OK,  "a*",                        "",                 (char*) 0      },
  { OK,  "a??",                       "a",                (char*) 0      },
  { OK,  "a?*",                       "a",                (char*) 0      },
  { OK,  "a?+",                       "a",                (char*) 0      },
  { OK,  "a*?",                       "a",                (char*) 0      },
  { OK,  "a**",                       "a",                (char*) 1      },
  { OK,  "a*+",                       "a",                (char*) 1      },
  { OK,  "a+?",                       "a",                (char*) 0      },
  { OK,  "a+*",                       "a",                (char*) 1      },
  { OK,  "a++",                       "a",                (char*) 1      },

The Python code I tested:

#!/usr/bin/env python3                                                          
# -*- coding: utf-8 -*-                                                         

import re

# (1)                                                                           
print(re.match(r'a??', ""))
#=>  <re.Match object; span=(0, 0), match=''>                                   

print(re.match(r'a??', "a"))
#=>  <re.Match object; span=(0, 0), match=''>                                   

print(re.match(r'a*', ""))
#=>  <re.Match object; span=(0, 0), match=''>                                   

# (2)                                                                           
print(re.match(r'(?:a??)??', "a"))
#=> <re.Match object; span=(0, 0), match=''>                                    

print(re.match(r'(?:a??)*', "a"))
#=> <re.Match object; span=(0, 0), match=''>                                    

print(re.match(r'(?:a??)+', "a"))
#=> <re.Match object; span=(0, 0), match=''>                                    

print(re.match(r'(?:a*)??', "a"))
#=> <re.Match object; span=(0, 0), match=''>                                    

print(re.match(r'(?:a*)*', "a"))
#=> <re.Match object; span=(0, 1), match='a'>                                   

print(re.match(r'(?:a*)+', "a"))
#=> <re.Match object; span=(0, 1), match='a'>                                   

print(re.match(r'(?:a+)??', "a"))
#=> <re.Match object; span=(0, 0), match=''>                                    

print(re.match(r'(?:a+)*', "a"))
#=> <re.Match object; span=(0, 1), match='a'>                                   

print(re.match(r'(?:a+)+', "a"))
#=> <re.Match object; span=(0, 1), match='a'>                                   

from tiny-regex-c.

kokke avatar kokke commented on August 27, 2024

Hi @kkos and thanks for the notice πŸ‘

Could you please provide some code so I can be certain what cases we are talking about.

Could you perhaps make a PR editing some of https://github.com/kokke/tiny-regex-c/blob/master/tests/test1.c to showcase exactly the cases you're talking about in 1) 2) ?

That would help me understand your issue :)

from tiny-regex-c.

kokke avatar kokke commented on August 27, 2024

Hi @kkos and thanks for helping me understand the issue πŸ‘

I don’t think the nested operators are supported easily, but I will have a look and get back to you

from tiny-regex-c.

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.