Extracting multiple data with parse #93
-
Hello,
The result of parse nums rules is
But the result is the same. What am I missing? Could you please help? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
nums: "34 56 83 19"
digits: system/catalog/bitsets/numeric
parse nums [collect any [keep some digits | skip]]
;== ["34" "56" "83" "19"] or in your case: ints: copy []
rules: [some [copy int some digits (append ints int)| skip]]
parse nums rules
ints
;== ["34" "56" "83" "19"] Your error is, that you are appending just the last |
Beta Was this translation helpful? Give feedback.
-
Also if your input is just numbers with spaces as a delimiter, you can use: split "34 56 83 19" SP
;== ["34" "56" "83" "19"] |
Beta Was this translation helpful? Give feedback.
-
If you need integers directly from the collect [parse nums [some [copy int some digits (keep to integer! int) | skip]]]
;== [34 56 83 19] (If you have it in a function, don't forget to define |
Beta Was this translation helpful? Give feedback.
-
Another better way: parse nums [collect any [copy int some digits keep (to integer! int) | skip]]
== [34 56 83 19] As
|
Beta Was this translation helpful? Give feedback.
or in your case:
Your error is, that you are appending just the last
int
, having(append ints int)
outside thesome
block.