04:50 stanrifkin_ joined 04:52 stanrifkin left 15:33 Manifest0 joined
Manifest0 Hi! I'm trying to create a regular expression that will match the string "attrib='hello \"world\"!'" 15:34
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
How do i fix my regex to not have such warnings?
librasteve Manifest0 - let me take a look 15:59
iirc there is a special raku re syntax for matching balanced chars 16:01
Manifest0 i didn't find anything in the documentation 16:09
librasteve hmm - maybe that's only for Grammar tokens ... sorry
m: say q|attrib='hello "world"!'| ~~ / (\w+) '=' '(.*)' / 16:10
Raku eval 「attrib='hello "world"!'」 0 => 「attrib」 1 => 「hello "world"!」
librasteve ^ is this what you have in mind?
I am guessing that you want the result captured as name, value and that the double quotes are part of the value Str 16:11
Manifest0 kind of. The part after the =, can start with a ' or " 16:12
librasteve PS I am using the q-lang syntax q|xxx| at least to strip the outer quotes to try and reduce "quote noise"
Manifest0 like a xml attribute
lucs m: print (q[attrib='hello "world"!'] ~~ / <-[=]>+ '=' (<["']>) (.*?) $0/)[1] 16:13
camelia hello "world"!
Manifest0 lucs, that seems to work :-) 16:14
lucs m: print (q[attrib='hello "world"!'] ~~ / <?after '='> (<["']>) (.*?) $0/)[1] 16:15
camelia hello "world"!
Manifest0 what does the '?after' do ? 16:17
librasteve m: say ( q|attrib='hello "world"!'| ~~ / $<name>=[<-[=]>] '=' '$<value>=[.]' / )<value> 16:18
Raku eval 「hello "world"!」
librasteve m: say ~( q|attrib='hello "world"!'| ~~ / $<name>=[<-[=]>] '=' '$<value>=[.]' / )<value> 16:19
Raku eval Use of Nil in string context in block <unit> at main.raku line 1
librasteve m: say ( q|attrib='hello "world"!'| ~~ / $<name>=[<-[=]>] '=' '$<value>=[.]' / )<value>.Str
Raku eval Use of Nil in string context in block <unit> at main.raku line 1
Manifest0 This "say ( q|attrib='hello "world"!'| ~~ / $<name>=[<-[=]>] '=' '$<value>=[.]' / )<value>" doesn't work in my raku
lucs Manifest0: I'ts a zero-width assertion that matches after what is indicated.
librasteve oh Disrod bridge lost my *
scullucs Yeah, Discord vs IRC: don't always agree 🙂 16:20
librasteve ~( q|attrib='hello "world"!'| ~~ / $<name>=[<-[=]>*] '=' \'$<value>=[.*]\' /)<value>
m: my $s = q|attrib='hello "world"!'|; my regex name { <-[=]>* }; my regex value { .* }; say ~($s ~~ /<name> '=' <value>/)<value>; 16:24
Raku eval 'hello "world"!'
librasteve m: my $s = q|attrib='hello "world"!'|; my regex name { <-[=]>* }; my regex value { .* }; say ~($s ~~ /<name> '=' '<value>'/)<value>; 16:29
Raku eval hello "world"!
librasteve oops I forgot to strip the value ' 16:30
m: my $s = q|attrib='hello "world"!'|; my regex name { <-[=]>* }; my regex value { .* }; say ~($s ~~ /<name> '=' \'<value>\' /)<value>;
sorry for the overkill - I just wanted to see how this would look with nested named regexs 16:31
Manifest0 no worries. 16:36
I'm playing now with the lucs solution - with the zero width assertions, since i don't know how them
scullucs my $s = q|attrib="hello 'world'!"|; say ~($s ~~ / [$<name> = <-[=]>] '=' (<['"]>) [$<value> = (.*?)] $0/)<value>; 16:41
librasteve btw I was curious (friday afternoon!) and found this docs.raku.org/language/regexes#Til...structures 16:42
scullucs Hmm... Does it account for balancing?
librasteve docs.raku.org/language/regexes#Rec...ve_Regexes 16:45
yes
scullucs I should have kept reading apparently 🙂
librasteve m: my $paren = rx/ '(' <-[()]>* ')' || '('[ <-[()]>* <~~> <-[()]>* ]* ')' /; say '((5 + 2) × 6) = 42 (the answer)' ~~ $paren;
Raku eval 「((5 + 2) × 6)」
librasteve well I probably have more to learn ;-) 16:48
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. 16:49
17:41 lizmat_ joined 17:45 lizmat left 19:09 renormalist joined 19:10 renormalist left 19:14 renormalist joined 19:16 renormalist left, renormalist joined 19:23 renormalist left 19:25 renormalist joined 19:26 renormalist left 19:30 renormalist joined 22:40 renormalist left, renormalist joined
renormalist raku: say "HELLO"; 22:41
m: say "HELLO"; 22:42
camelia HELLO
renormalist Is there bash completion support somewhere for raku tools like mi6, zef, fez, etc.? 22:47
22:53 Manifest0 left 23:26 lizmat_ left, lizmat joined 23:39 stanrifkin_ left