-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Hi all,
I'm trying to substitute parts of a string, and thought this might be a good use of a grammar. Sadly, grammars aren't my strong suit, so I thought I'd ask the wider community for help. Maybe you guys know an even better solution than using a grammar here. So, consider a string, "Here be a $(placeholder), for $(purpose) purposes.". I want to be able to put that into a sub, along with some Pairs, and get a string with the placeholders replaced back. my Str $input = "Here be a $(placeholder), for $(purpose) purposes."; my Str $output = format-string( $input, placeholder => "placeholder", purpose => "testing", ); dd $output; # "Here be a placeholder, for testing purposes." The `format-string` sub would call the grammar and apply the actual substitution, and that's where I need your help. I am not quite sure how I would implement the grammar (and presumably it's actions) to do what I want. Thanks in advance for your help! - -- With kind regards, Patrick Spek www: https://www.tyil.work/ mail: p.s...@tyil.nl pgp: EB9E A484 1672 2D37 16F5 A799 9ACF E193 FFBC 1F50 mastodon: @tyil@mastodon.social github: @Tyil gitlab: @tyil -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEE4eL662U9iK2ST2MqN/W6H45XOE8FAluFIw0ACgkQN/W6H45X OE+9pAgAry3KwoOS+A5g+y9V0hPHx24nQ6U8TcbZh/HIuvwwbinkCi4oxfhGwTBX FXeogYj18OF+K7KEq45fAtB7sqrAelo59elu+ZCXZmiFH1BNHFNWbINkKKWQdHAs uYTL7poMwSQ+XQVBTCu3dY32jVl3qasSr4dAM0g6za8TTtgw0TTblF/aNO6A0KC6 cf757hWxZ7VqprIbpPfvQnB/0BreVu467Va7EGdzZDwi3WfQTg9R0H1NTSkpdS0M fyhMJ21rjBhhiUZt+DOHThcd5s7ikk1d1fX5x/hEgRNIcmbQVZ7N3STGSxtqFm6h thQ2zhTXGgE/VrTaOHP0a8NiqPamEQ== =RlqT -----END PGP SIGNATURE-----