Home > Rant > regex bug in ms visual c++ 2010

regex bug in ms visual c++ 2010

I couldn’t work on zkanji during the past 2 weeks (and this is still going on), I was writing something in msvcpp2010 instead. (Don’t ask what.)

Here is a simple regular expression string: (You will need to add extra backslashes as escape characters if you are trying this out.)
\s*([^ ]+)\s*([^ ]*)(?:\s*=\s*”(.*)”)?\s*

It’s purpose is to look for some word having no spaces and store it, look for another word having no spaces and store that too (optional), find an equal sign and a third word having any characters, but between quotation marks, (this third word with the equal sign is optional too) and store that word but without the quotation marks.

But I got strange results. When there is a third word, the second quotation mark is stored after the word. (i.e. ‘Look = “Here”‘ will give ‘Here”‘ as the third word. (The “second word” is the empty string in this case.) ) This is a bug, and I’m sure about it because the result is correct when I run the same expression under the PERL interpreter. Why is it, that such huge companies like Microsoft can afford to have stupid bugs in their sloppy libraries? (Apparently it’s because they don’t have to care, as they still earn billions anyway.) This is not even a complex regular expression you would never need, but something so common (like teenagers studying Japanese because they saw some anime).

 

This entry has nothing to do with zkanji nor Japanese, I just had to vent my frustration. See you soon when I once again set out to finish the next version of zkanji!

Advertisements
Categories: Rant
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: