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

Null terminator always matched as last character in Regex #19802

Closed
lv37 opened this issue Nov 7, 2023 · 0 comments · Fixed by #20104
Closed

Null terminator always matched as last character in Regex #19802

lv37 opened this issue Nov 7, 2023 · 0 comments · Fixed by #20104
Labels
Bug This tag is applied to issues which reports bugs. Unit: vlib Bugs/feature requests, that are related to the vlib.

Comments

@lv37
Copy link
Contributor

lv37 commented Nov 7, 2023

Describe the bug

import regex

fn main() {
	re1 := regex.regex_opt('^abc\0$')!
	assert re1.matches_string('abc') == false // should be false but is true
	assert re1.matches_string('abc\0') == true // works as expected

	re2 := regex.regex_opt('^abc\0xyz$')!
	assert re2.matches_string('abc' + 'xyz') == false // works as expected
	assert re2.matches_string('abc\0xyz') == true // works as expected
}

Reproduction Steps

Run the above code

Expected Behavior

run successfully

Current Behavior

src/main.v:5: FAIL: fn main.main: assert re1.matches_string('abc') == false
   left value: re1.matches_string('abc') = true
  right value: false
V panic: Assertion failed..

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.2 d86b368

Environment details (OS name and version, etc.)

V full version: V 0.4.2 4bc9a8f.d86b368
OS: linux, Linux version 6.5.9-200.fc38.x86_64 (mockbuild@1cc7d6d790524511abd343182a21832a) (gcc (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4), GNU ld version 2.39-15.fc38) #1 SMP PREEMPT_DYNAMIC Wed Oct 25 20:40:49 UTC 2023
Processor: 4 cpus, 64bit, little endian, Intel(R) Core(TM) i5-4310U CPU @ 2.00GHz

getwd: /home/user/Projects/v-testing/hypixel
vexe: /home/user/.local/lib/v/v
vexe mtime: 2023-11-07 14:28:20

vroot: OK, value: /home/user/.local/lib/v
VMODULES: OK, value: /home/user/.vmodules
VTMP: OK, value: /tmp/v_1002

Git version: git version 2.41.0
Git vroot status: weekly.2023.44-76-gd86b3689
.git/config present: true

CC version: cc (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4)
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3

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.

@lv37 lv37 added the Bug This tag is applied to issues which reports bugs. label Nov 7, 2023
@felipensp felipensp added the Unit: vlib Bugs/feature requests, that are related to the vlib. label Nov 21, 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. Unit: vlib Bugs/feature requests, that are related to the vlib.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants