Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V-Regex Bug with the negation of slash (/) #19789

Closed
noxomix opened this issue Nov 6, 2023 · 1 comment
Closed

V-Regex Bug with the negation of slash (/) #19789

noxomix opened this issue Nov 6, 2023 · 1 comment
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@noxomix
Copy link

noxomix commented Nov 6, 2023

Describe the bug

This Bug occurs in the vlang regex module , with the following: [^/]+. (and pretty sure also with the * instead + ; not tested more)

Reproduction Steps

import regex

fn main() {
    re := regex.regex_opt(r'^/admin/[^/]+$') or { panic(0) }
    if re.matches_string('/admin/something') {
        //should match
        println('This is ok and should match!')
    }
    if re.matches_string('/admin/') {
        //should NOT match
        println('This should not be matched...')
    }
    if re.matches_string('/admin') {
        //should NOT match
        println('This is not matched tho...')
    }
}

Expected Behavior

Im expecting to match everything except slash (/)

So this should be matched:
/admin/something or this /admin/124

This should not (!) be matched:
/admin/, /admin, /admin/something/other

Current Behavior

/admin/ is getting matched but no character is provided behind the last slash so why is this matching (?)

Possible Solution

I have no idea but maybe it has something todo with the piviot ? Because it is used for negation + for marking the "start of a string".

Additional Information/Context

This is my regex: ^/admin/[^/]+$

But its also not working without the $ and without the first ^...

I tried with flags aswell, like this rg_bin or how its called again and so on.

V version

0.4.2 1c4c505

Environment details (OS name and version, etc.)

ZorinOS 16.3 (Linux, Debian/Ubuntu based)
64 Bit AMD Ryzen 5xxx-laptop CPU

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@noxomix noxomix added the Bug This tag is applied to issues which reports bugs. label Nov 6, 2023
penguindark added a commit to penguindark/v that referenced this issue Nov 6, 2023
spytheman pushed a commit that referenced this issue Nov 7, 2023
@noxomix
Copy link
Author

noxomix commented Nov 7, 2023

Thank you ;)

@noxomix noxomix closed this as completed Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

No branches or pull requests

1 participant