[04:50] *** stanrifkin_ joined
[04:52] *** stanrifkin left
[15:33] *** Manifest0 joined
[15:34] <Manifest0> Hi! I'm trying to create a regular expression that will match the string "attrib='hello \"world\"!'"

[15:35] <Manifest0> I came up with /\w+ '=' (<["'" '"']>) (.*?) $0/ but i get several warnings such as: Quotes are not metacharacters in character classes, Repeated character (") unexpectedly found in character class, and Repeated character (') unexpectedly found in character class 

[15:35] <Manifest0> How do i fix my regex to not have such warnings?

[15:59] <discord-raku-bot> <librasteve> Manifest0 - let me take a look

[16:01] <discord-raku-bot> <librasteve> iirc there is a special raku re syntax for matching balanced chars

[16:09] <Manifest0> i didn't find anything in the documentation

[16:09] <discord-raku-bot> <librasteve> hmm - maybe that's only for Grammar tokens ... sorry

[16:10] <discord-raku-bot> <librasteve> m: say q|attrib='hello "world"!'| ~~ / (\w+) '=' '(.*)' /

[16:10] <discord-raku-bot> <Raku eval>  ｢attrib='hello "world"!'｣  0 => ｢attrib｣  1 => ｢hello "world"!｣ 

[16:10] <discord-raku-bot> <librasteve> ^ is this what you have in mind?

[16:11] <discord-raku-bot> <librasteve> I am guessing that you want the result captured as name, value and that the double quotes are part of the value Str

[16:12] <Manifest0> kind of. The part after the =, can start with a ' or "

[16:12] <discord-raku-bot> <librasteve> PS I am using the q-lang syntax q|xxx| at least to strip the outer quotes to try and reduce "quote noise"

[16:12] <Manifest0> like a xml attribute

[16:13] <lucs> m: print (q[attrib='hello "world"!'] ~~ / <-[=]>+ '=' (<["']>) (.*?) $0/)[1]

[16:13] <camelia> rakudo-moar 7c412a11b: OUTPUT: «hello "world"!»

[16:14] <Manifest0> lucs, that seems to work :-)

[16:15] <lucs> m: print (q[attrib='hello "world"!'] ~~ / <?after '='> (<["']>) (.*?) $0/)[1]

[16:15] <camelia> rakudo-moar 7c412a11b: OUTPUT: «hello "world"!»

[16:17] <Manifest0> what does the '?after' do ?

[16:18] <discord-raku-bot> <librasteve> m: say ( q|attrib='hello "world"!'| ~~ / $<name>=[<-[=]>] '=' '$<value>=[.]' / )<value>

[16:18] <discord-raku-bot> <Raku eval>  ｢hello "world"!｣ 

[16:19] <discord-raku-bot> <librasteve> m: say ~( q|attrib='hello "world"!'| ~~ / $<name>=[<-[=]>] '=' '$<value>=[.]' / )<value>

[16:19] <discord-raku-bot> <Raku eval>    Use of Nil in string context   in block <unit> at main.raku line 1 

[16:19] <discord-raku-bot> <librasteve> m: say ( q|attrib='hello "world"!'| ~~ / $<name>=[<-[=]>] '=' '$<value>=[.]' / )<value>.Str

[16:19] <discord-raku-bot> <Raku eval>    Use of Nil in string context   in block <unit> at main.raku line 1 

[16:19] <Manifest0> This  "say ( q|attrib='hello "world"!'| ~~ / $<name>=[<-[=]>] '=' '$<value>=[.]' / )<value>" doesn't work in my raku

[16:19] <lucs> Manifest0: I'ts a zero-width assertion that matches after what is indicated.

[16:19] <discord-raku-bot> <librasteve> oh Disrod bridge lost my *

[16:20] <discord-raku-bot> <scullucs> Yeah, Discord vs IRC: don't always agree 🙂

[16:20] <discord-raku-bot> <librasteve> ~( q|attrib='hello "world"!'| ~~ / $<name>=[<-[=]>*] '=' \'$<value>=[.*]\' /)<value>

[16:24] <discord-raku-bot> <librasteve> m: my $s = q|attrib='hello "world"!'|; my regex name { <-[=]>* }; my regex value { .* }; say ~($s ~~ /<name> '=' <value>/)<value>;

[16:24] <discord-raku-bot> <Raku eval>  'hello "world"!' 

[16:29] <discord-raku-bot> <librasteve> m: my $s = q|attrib='hello "world"!'|; my regex name { <-[=]>* }; my regex value { .* }; say ~($s ~~ /<name> '=' '<value>'/)<value>;

[16:29] <discord-raku-bot> <Raku eval>  hello "world"! 

[16:30] <discord-raku-bot> <librasteve> oops I forgot to strip the value '

[16:30] <discord-raku-bot> <librasteve> m: my $s = q|attrib='hello "world"!'|; my regex name { <-[=]>* }; my regex value { .* }; say ~($s ~~ /<name> '=' \'<value>\' /)<value>;

[16:31] <discord-raku-bot> <librasteve> sorry for the overkill - I just wanted to see how this would look with nested named regexs

[16:36] <Manifest0> no worries.

[16:36] <Manifest0> I'm playing now with the lucs solution - with the zero width assertions, since i don't know how them

[16:41] <discord-raku-bot> <scullucs> my $s = q|attrib="hello 'world'!"|; say ~($s ~~ / [$<name> = <-[=]>] '=' (<['"]>) [$<value> = (.*?)] $0/)<value>; 

[16:42] <discord-raku-bot> <librasteve> btw I was curious (friday afternoon!) and found this https://docs.raku.org/language/regexes#Tilde_for_nesting_structures

[16:42] <discord-raku-bot> <scullucs> Hmm... Does it account for balancing?

[16:45] <discord-raku-bot> <librasteve> https://docs.raku.org/language/regexes#Recursive_Regexes

[16:45] <discord-raku-bot> <librasteve> yes

[16:45] <discord-raku-bot> <scullucs> I should have kept reading apparently 🙂

[16:45] <discord-raku-bot> <librasteve> m: my $paren = rx/ '(' <-[()]>* ')' || '('[ <-[()]>* <~~> <-[()]>* ]* ')' /; say '((5 + 2) × 6) = 42 (the answer)' ~~ $paren;

[16:45] <discord-raku-bot> <Raku eval>  ｢((5 + 2) × 6)｣ 

[16:48] <discord-raku-bot> <librasteve> well I probably have more to learn ;-)

[16:49] <discord-raku-bot> <scullucs> I'm always amazed by how much stuff I can do with Raku compared to how much more of it I need to learn.

[17:41] *** lizmat_ joined
[17:45] *** lizmat left
[19:09] *** renormalist joined
[19:10] *** renormalist left
[19:14] *** renormalist joined
[19:16] *** renormalist left
[19:16] *** renormalist joined
[19:23] *** renormalist left
[19:25] *** renormalist joined
[19:26] *** renormalist left
[19:30] *** renormalist joined
[22:40] *** renormalist left
[22:40] *** renormalist joined
[22:41] <renormalist> raku: say "HELLO";

[22:42] <renormalist> m: say "HELLO";

[22:42] <camelia> rakudo-moar 7c412a11b: OUTPUT: «HELLO␤»

[22:47] <renormalist> Is there bash completion support somewhere for raku tools like mi6, zef, fez, etc.?

[22:53] *** Manifest0 left
[23:26] *** lizmat_ left
[23:26] *** lizmat joined
[23:39] *** stanrifkin_ left
