Trying to build a regex to retrieve/select elements in an encoded string depending some keyboard signs order:
str = "(abc-1é,d[efg_2ç;i|jkl+3ö.(mno?4à,p[qr(st!5',uv#6^;|xyz%7_." // look strange :)
I need to retrieve all parts included
1) in ( , -> "abc-1é" + "mno?4à" + "st!5'"
2) in [ ; -> "efg_2ç" + "qr(st!5,uv#6^"
3) in | . -> "jkl+3ö" + "xyz%7_"
I've tried a lot of possibilities on https://regex101.com/ and I'm able to produce some right results:
/\(([^()]*),/g -> catch "(abc-1é," "(mno?4à," and "(st!5'," -> OK
/\|[\w()]{0,}(...)./g -> catch "|jkl+3ö." and "|xyz%7_." -> OK
Don't ask me why but it works, except:
/\[([^()]*);/g or /\[[\w()]{0,}(...);/g -> catch "[efg_2ç;" but ignore "[qr(st!5',uv#6^;"
My question is: is it possible to create an unique regex able to capture the 3 signs-conditions? something like:
/ init: \[|\(|\| -> inside: [all founded signs, any length] -> end: ,|.|; /g
and (if possible) with some explanations... Thx in advance
[qr(st!5',uv#6^;works well if signs ! ' and , are declared in the regex[[\w(),!']{0,}(...);matchAllresults that get destructured/flattened into a single array and then reduced or mapped. This also helps readability and refactoring/maintenance.(a:b,A[c>d;|B[c>d;.once decoded saysif (number of votes > 10) { Approve(name,decision) } else { Reject(name,decision) }Each actor will be able to safely store its own conditions.