-
Notifications
You must be signed in to change notification settings - Fork 23
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
How to use std.split
pattern argument?
#9
Comments
Side question... how do I take a range of elements from an array? Specifically where I do not know the length of the elements. Using the example above, I would like to skip the first line of output (I know I could clean the output before it enters hush) and only process the one or more following lines of output. Python has a short syntax for this like the following: I've been enjoying hush otherwise. Thanks for making something fun to try out, your docs were enjoyable :) |
A regex API is surely a must, and it's on my high priority list. Currently, Regarding slicing the array, I would be more favorable to using an iterator in that case. To skip the first line, you could do:
|
I have made a new release with an API for regex. Take a look at std.regex Your script using this new API would be:
Outputs:
|
Amazing! Thanks for the quick turn-around. I'll play with it again soon :) |
Tested it out, everything works as expected so far. Closing the issue for now. Thanks again! |
Hello, I was playing around with hush tonight and wanted to split a line based on whitespace and was struggling to get a pattern to work. I dug through the docs and the repo and couldn't find any information on how it splits on pattern and what type of patterns it supports.
I noticed that the std.split implementation calls a
split_str
method. I'm no rust developer, so I'm not sure exactly what's happening in that code, but I was unable to follow any further to figure out whatsplit_str
does with the provided pattern.Here's the code I'm playing with:
With the following output:
tl;dr how to split a string based on a regex pattern?
The text was updated successfully, but these errors were encountered: