00:27 melezhik joined 00:28 melezhik left 05:12 ajr joined 06:41 ajr left 12:18 sm2 left 13:51 A26F64 joined
Nemokosch what's the idiomatic way to split a string by words? 16:24
[Coke] m: "this string".words.say 16:25
camelia (this string)
[Coke] m: dd "this string".words #better formatted
camelia ("this", "string").Seq
lizmat of course, that is dividing by whitespace, which you may not consider to be "words" 16:27
m: dd "this: string!".comb( / \w+ / ) 16:28
camelia ("this", "string").Seq
lizmat if you'd like the other interpretation of "words"
Nemokosch thankies 17:19
19:43 ajr joined 20:05 ajr left 20:17 ajr joined 20:22 ajr left 20:49 ajr joined 20:53 ajr left
And how do I get all the regex matches to a certain pattern? 21:03
[Coke] ? 21:04
Nemokosch like matchAll in Javascript 21:05
lizmat m: .say for "foo" ~~ m:g/./ # this perhaps? 21:07
camelia ï½¢fï½£
ï½¢oï½£
ï½¢oï½£
lizmat m: .say for "foo".match(/./, :g) # or this ? 21:08
camelia ï½¢fï½£
ï½¢oï½£
ï½¢oï½£
21:11 ajr joined
Nemokosch are they the same thing? 21:12
okay, I went with ~~ m:g// 21:32
this sets $/
so the iteration of $/ (which really looks like a list) is strange in this case 21:33
maybe this is because of the sigil
22:09 A26F64 left 22:11 sm2 joined
Morfent m:``` 22:34
say WHAT VAR 'foo' ~~ m:g/./;
say WHAT VAR $/;
```
Nemokosch can I just override it? 22:35
22:35 ajr left
Morfent the `Scalar`? 22:36
Nemokosch yes 22:37
Morfent m:```
say WHAT VAR $('foo' ~~ m:g/./);
say WHAT VAR $/<>;
```
22:47 ajr joined
Nemokosch what about @$/ ? 22:59
what about `@$/` ?
Morfent that would also work 23:03
Nemokosch cool 🙂 23:14
lizmat yeah, you should realize that $0 is just short for $/[0] and $<foo> if short for $/<foo> 23:17
m: $/ = { a => 42 }; dd $<a>
camelia Int % = 42
lizmat m: $/ = (1,2,3); dd $0
camelia 1
Nemokosch yes, I realized that 23:21
but in this case I wanted to loop over $/ because it was a list of matches 23:22
so I didn't even want to use $1 $2 etc
23:37 sm2 left
[Coke] m: for 'foo' ~~ m:g/./ -> $a { dd $a } 23:59
camelia Match.new(:orig("foo"), :from(0), :pos(1))
Match.new(:orig("foo"), :from(1), :pos(2))
Match.new(:orig("foo"), :from(2), :pos(3))