A program that separates these out of that config file/representation/whatever this is (idk what Okta is tbh) into individual substrings is really easy
I actually wrote a regex that matches each username in that structure for fun lol: (?<=[\[| ])[a-zA-Z0-9_]+ but you can match regex with regex too (It's long as hell though, relatively)
You can try it in your browser at: https://regex101.com/
Idk why they called that field .*regex though, probably cuz it's fake
Wait I can write a better regex lol
Edit: this will match all substrings properly inside that structure, including more regexes, correctly(edit edit: WRONG!): (?<=[\[| ])[^,]+(?=[,|\]])
Edit edit: It's all fucked and my brain hurts now because I wanted to match any valid regex inside of that structure, separately
I will be back with the ultimate regex later, probably recursive and with the caveat that if you want to use comma literals, you will have to escape them, call that shit X-regex (special X.com regex syntax)
I am going to bed I am so tired
I'm sorry, there's no way I can write this in a sane-sounding way, it's been a journey and I'm probably drastically overcomplicating this
I should not have said that, I'm sorry I was really tired, but I think it's also more complicated than no
Many implementations of "regular expressions" are actually capable of describing more than regular languages
Like Perl/PCRE's regular expression parser (which I used to write the above regexes) is capable of recursive evaluation and backreferences and probably other stuff I don't know about cuz I don't use it very often
I don't actually know if you can or not but yeah
Tbh, you probably know more about formal language theory than me
Hi, idk if you saw my other reply, but I have returned with the promised regular expression capable of doing this (at least when parsed by PCRE and similar)
(?<=(?<!\\)\[|(?<!\\), ).*?(?=(?<!\\)]|(?<!\\),)
It will match each username/regex matching usernames as an individual substring
In the end I didn't need recursion and managed to accomplish the task by using nested lookarounds and making the assumption that brackets and commas are escaped with backslashes. It could probably be further simplified by using subroutines that some regex parsers are capable of using. Also it is most likely possible to write a regex that doesn't require escaping brackets, besides when you need to escape brackets when writing regexes anyway ofc. The requirement that commas be escaped is analogous to requiring that quotes be escaped inside a string literal if instead the usernames/regexes that match usernames were enclosed in quotes
I uhhhh don't write many regexes
There's probably something to be said about this task being easier to accomplish in languages "more powerful" (in terms: "Chomsky hierarchy") than regular languages but I'm not (-free languages, etc )
I have a tendency toward owning myself, if you find a way to break my regex without breaking the assumptions specified above I will be further owned
I saw your comments. I was trying to get home and use my FreeBSD machine to reply since I was on mobile today and of course amdgpu decided to start causing kernel panics so it ate all my time. I'll respond probably tomorrow evening.
You've done enough work where it is worth having a full discussion instead of trying to type something up on my mobile device. It's all good stuff, you put the work in
Ohh, you're good, I hope I didn't make you feel pressured to reply or anything. Sometimes I just start writing and it ends up being a lot lol, besides I just like writing regular expressions sometimes lol
Also to another BSD user. I'm speaking to you with an OpenBSD machine rn lol. I hope you got your kernel panicking fixed
Post stack trace here if you want help perhaps, I've also had to debug BSD kernels before (although the graphics stuff is mostly ripped straight from Linux lol)
Here's the the thing. The snippet that was posted by that account is not any known format. It's not YAML, it's not INI syntax, it's not JSON, or TOML, or anything that is a common configuration syntax. It's not valid JS. It's bullshit. It's just close enough to programming code that it would maybe convince some people.
So, while you spent a lot of time proving that you if you were forced to work with this file, there's an incredibly nasty set of regex and parsing that you could do to make this actually work, there's absolutely no reason why this would be done.
People rolling their own formats isn't really that uncommon. And besides, that file is one s/ =/:/g away from being valid YAML. There might even be a YAML or TOML parser around that will accept this, idk
there's an incredibly nasty set of regex and parsing that you could do to make this actually work
It only really looks nasty cuz I wanted to "parse" this file mentioning regex with regex for fun lol, it's basically YAML
The syntax of that file isn't the sus part imo. I feel like I'm being an annoying pedant but yeah
See the thing is, they're not even strings. They're not enclosed in quotes.
A program that separates these out of that config file/representation/whatever this is (idk what Okta is tbh) into individual substrings is really easy
I actually wrote a regex that matches each username in that structure for fun lol:
(?<=[\[| ])[a-zA-Z0-9_]+
but you can match regex with regex too (It's long as hell though, relatively)You can try it in your browser at: https://regex101.com/
Idk why they called that field .*regex though, probably cuz it's fake
Wait I can write a better regex lol
Edit: this will match all substrings properly inside that structure, including more regexes, correctly(edit edit: WRONG!):
(?<=[\[| ])[^,]+(?=[,|\]])
Edit edit: It's all fucked and my brain hurts now because I wanted to match any valid regex inside of that structure, separately
I will be back with the ultimate regex later, probably recursive and with the caveat that if you want to use comma literals, you will have to escape them, call that shit X-regex (special X.com regex syntax)
I am going to bed I am so tired
I'm sorry, there's no way I can write this in a sane-sounding way, it's been a journey and I'm probably drastically overcomplicating this
You can't because the regular languages cannot describe properly nested parentheses.
I should not have said that, I'm sorry I was really tired, but I think it's also more complicated than no
Many implementations of "regular expressions" are actually capable of describing more than regular languages
Like Perl/PCRE's regular expression parser (which I used to write the above regexes) is capable of recursive evaluation and backreferences and probably other stuff I don't know about cuz I don't use it very often
I don't actually know if you can or not but yeah
Tbh, you probably know more about formal language theory than me
Hi, idk if you saw my other reply, but I have returned with the promised regular expression capable of doing this (at least when parsed by PCRE and similar)
(?<=(?<!\\)\[|(?<!\\), ).*?(?=(?<!\\)]|(?<!\\),)
It will match each username/regex matching usernames as an individual substring
In the end I didn't need recursion and managed to accomplish the task by using nested lookarounds and making the assumption that brackets and commas are escaped with backslashes. It could probably be further simplified by using subroutines that some regex parsers are capable of using. Also it is most likely possible to write a regex that doesn't require escaping brackets, besides when you need to escape brackets when writing regexes anyway ofc. The requirement that commas be escaped is analogous to requiring that quotes be escaped inside a string literal if instead the usernames/regexes that match usernames were enclosed in quotes
I uhhhh don't write many regexes
There's probably something to be said about this task being easier to accomplish in languages "more powerful" (in terms: "Chomsky hierarchy") than regular languages but I'm not (-free languages, etc )
I have a tendency toward owning myself, if you find a way to break my regex without breaking the assumptions specified above I will be further owned
I saw your comments. I was trying to get home and use my FreeBSD machine to reply since I was on mobile today and of course amdgpu decided to start causing kernel panics so it ate all my time. I'll respond probably tomorrow evening.
You've done enough work where it is worth having a full discussion instead of trying to type something up on my mobile device. It's all good stuff, you put the work in
Ohh, you're good, I hope I didn't make you feel pressured to reply or anything. Sometimes I just start writing and it ends up being a lot lol, besides I just like writing regular expressions sometimes lol
Also to another BSD user. I'm speaking to you with an OpenBSD machine rn lol. I hope you got your kernel panicking fixed
Post stack trace here if you want help perhaps, I've also had to debug BSD kernels before (although the graphics stuff is mostly ripped straight from Linux lol)
deleted by creator
Ohh, I see, that sounds difficult to fix :( , good luck
Okay!
Here's the the thing. The snippet that was posted by that account is not any known format. It's not YAML, it's not INI syntax, it's not JSON, or TOML, or anything that is a common configuration syntax. It's not valid JS. It's bullshit. It's just close enough to programming code that it would maybe convince some people.
So, while you spent a lot of time proving that you if you were forced to work with this file, there's an incredibly nasty set of regex and parsing that you could do to make this actually work, there's absolutely no reason why this would be done.
People rolling their own formats isn't really that uncommon. And besides, that file is one
s/ =/:/g
away from being valid YAML. There might even be a YAML or TOML parser around that will accept this, idkIt only really looks nasty cuz I wanted to "parse" this file mentioning regex with regex for fun lol, it's basically YAML
The syntax of that file isn't the sus part imo. I feel like I'm being an annoying pedant but yeah