This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
Set by lizmat on 8 June 2022.
01:12 deoac joined 02:35 razetime joined 03:48 deoac left 05:11 razetime left 05:34 razetime joined 05:42 siavash joined 06:06 razetime left 06:14 razetime joined 06:27 razetime left 07:01 samebchase left 07:45 razetime joined 08:02 snonux left 08:05 siavash left 08:19 teatwo joined 08:20 teatwo left 08:21 teatwo joined 08:22 snonux joined, tea3po left 10:31 razetime left 10:45 razetime joined 11:23 razetime left 12:59 lizmat_ joined 13:02 lizmat left 14:56 lizmat_ left, lizmat joined 20:19 tea3po joined 20:20 tea3po left, tea3po joined 20:22 teatwo left 20:26 habere-et-disper joined 20:56 habere-et-disper left
antononcube I expect the following code to produce "and 23_321_900 this", not "and 23_321,900 this". Where I am wrong? How can I do that? ‌‌my $input = 'and 23,321,900 this'; $input.subst(/(\d) ',' (\d**3)/, {"$0_$1"}):g # and 23_321,900 this 21:02
21:37 deoac joined 21:50 yjh left 21:51 yjh joined
I found a clunky solution. I still I do not understand why the adverb :g does not have effect. (I just have a few iffy conjectures...) 21:57
_elcaro_ I would just use a Capture Marker [0] > my $input = 'and 23,321,900 this'; and 23,321,900 this [1] > $input.subst(/',' )> \d**3 /, "_", :g) and 23_321_900 this 22:04
More verbose with look-around assertions: $input.subst(/','<?before \d**3> /, "_", :g) 22:06
22:08 RakuIRCLogger left
nemokosch are you sure that adverb was even at a valid position? 22:09
_elcaro_ Yeah, it will still work with the adverb outside the parens 22:10
nemokosch well if it does, that's easier to validate 😼 ⌨️ 22:11
yep 22:12
_elcaro_ I think the problem with Anton's original expression is... since the match includes those 3 numbers, the cursor moves to the end of the match, so it can't then use the last digit in the beginning of the next match. I've often thought that having :exhaustive available on subst would be nice to have > say .Str for $input ~~ m:g/\d','(\d**3)/ 3,321 > say .Str for $input ~~ m:ex/\d','(\d**3)/ 3,321 1,900 22:20
antononcube My clunky solution is based on exhaustive match like yours. 22:24
It does make sense to use look around assertions instead. 22:25
22:53 deoac left