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

regex: fix regex.split() (fix #16876) #21953

Merged
merged 1 commit into from
Jul 29, 2024
Merged

Conversation

yuyi98
Copy link
Member

@yuyi98 yuyi98 commented Jul 28, 2024

This PR fix regex.split() (fix #16876).

  • Fix regex.split().
  • Add test.
import regex

fn main() {
	mut r := regex.regex_opt('-') or { panic(err) }
	println(r.split('a-'))
	println('a-'.split('-'))
	println(r.split('-a'))
	println('-a'.split('-'))
}

PS D:\Test\v\tt1> v run .
['a', '']
['a', '']
['', 'a']
['', 'a']

@penguindark
Copy link
Member

Good work! For me it is ok!

Copy link
Member

@penguindark penguindark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good for me, thanks for the fix.

@spytheman spytheman merged commit 5e435a7 into vlang:master Jul 29, 2024
61 checks passed
@yuyi98 yuyi98 deleted the fix_regex_split branch July 29, 2024 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

regex.split doesn't report leading/trailing empty splits
3 participants