Yesterday I was working on a bit of code that had to read the XMP meta data from a file. It is not located at a certain position, so I had to scan the file. XMP, being plain XML, can be found by simple string matching. After some searching I’ve found many solutions that read the entire file into memory and perform a regular expression search or a string comparison. That’s not going to work for me, because I have files that are +100MB! So I wrote some code that does a search that performs.
PowerShell is very similar to .NET, so it is no surprise that it is very popular with .NET developers. It is a language for writing scripts, so you might encounter some unexpected situations. I had this experience when I tried to parse some HTML with PowerShell: I could not get the replacement with regular expression groups to work! It turned out that my .NET knowledge was working against me…
As a developer, I love to solve common string problems with regular expression. Sure, they are sometimes hard to read, but you can do so much with such a small expression! It is nice that many languages have support for them, but sometimes it feels like every language creates its own dialect. Let’s look at the difference between regular expression groups in .NET and JavaScript.