Doorgaan naar hoofdcontent

Posts

Posts uit februari, 2021 tonen

Java sux with regexes

 Java supports regexes right? Nothing to it! that is so nice about it Only after 15 years, I find out that it does have performance problems. https://bugs.java.com/bugdatabase/view_bug.do?bug_id=5050507  Is a bug for regexes in java. Of course, they're rare. But how did I hit it? Well, doing stuff you shouldn't of course. In this case, parsing Json, by searching for a value of a certain key. That's straightforward, right? "key"\s:\s"([^"]+)" Well, it would be nice like that, but there's this tiny exception... the value can contain quotes as well. Okay, so we exclude them. Numerous posts tell you how to do it. The trick is to use an or, in essence saying: 'the string \" OR any character which is not a "`  We can see that in action  here All languages support it.   but.... not java. No, it has problems with these groups. It gives stack overflows. And it's a known fact. So, is this the end? I thought so. But then, I started diggi...