REGEX and MySQL

I’m working on my words database using phpMyAdmin and thought others might benefit from some of the search expressions.

Find words that start with ‘Wr’ or ‘wr’ and the CVC category is not null.


SELECT *  FROM `words` WHERE `word` REGEXP '^[Ww]r[a-z]*' 
AND `CVC` IS NOT NULL

This gives me words like, Rhoda, Rhone, rhyme because I’m asking to start at the beginning of the word ‘^’ then look for either a capital or lowercase w ‘[Ww] followed by an ‘r’ and then any letter ‘[a-z]’ that occurs zero or more times ‘*’. I’m further restricting the search to words that have an entry in the CVC category. In phpMyAdmin you can paste this into the SQL editing field or just use the REGEX in the word field and set it to REGEXP.

Here’s one looking for all the words that end in the letters mb and the CVC category is not null.


SELECT *  FROM `words` WHERE `word` REGEXP 'mb$' 
AND `CVC` IS NOT NULL

The ‘$’ means the end of the word.

This search yields words like climb, plumb, thumb.

This search looks for words like gnome and gnat. If you want you can leave out the [a-z]* and you’ll get the same result.


SELECT *  FROM `words_for_slps` WHERE `word` REGEXP '^[Gg]n[a-z]*' 
AND `CVC` IS NOT NULL

This one’s a little more complicated, I’m looking for words like tongue and dengue but don’t know if there are words with gue in the middle—like tongues.


SELECT *  FROM `words_for_slps` WHERE `word` REGEXP '^[a-zA-z]*ngue[a-z]*' 
AND `CVC` IS NOT NULL

You can’t do OR queries in phpMyAdmin interface everything is an AND. But if you do a query, then edit the SQL it is easy to make the query into an OR.

This is the original query to find words where the grade and level are NULL.


SELECT *  FROM `words_for_slps` WHERE `level` IS NULL AND `grade` IS NULL 
AND `CVC` IS NOT NULL

And here is the same code where all I changed is the AND to OR and just to be sure I’m getting the right results, I grouped the OR with parentheses. (I can never the default rules for the different languages so I always use parentheses so I’m sure I get what I want.)


SELECT *  FROM `words_for_slps` WHERE (`level` IS NULL OR `grade` IS NULL) 
AND `CVC` IS NOT NULL

I like this result but want to look deal with the shorter words first and then work my way up to the harder ones. I also want to skip the words that do not follow the rules (DNFR). Use <> for not equal.


SELECT *  FROM `words_for_slps` WHERE (`level` IS NULL OR `grade` IS NULL) 
AND `CVC` IS NOT NULL AND `CVC` <> 'DNFR' ORDER BY LENGTH(word)

Here’s the code I use to find all of the conosonants


([bcdfghjklmnpqrstvwxz]|ch|sh|zh|th|wh|ng|qu|wh|tch|ph)

And this finds all the vowels.


(a|e|i|o|u|aw|ow|ie|ae|oe|oy|oo|uu|y)

And this finds all of the CVCCV words. Note the {2} that finds exactly two occurrences of the previous search string.


SELECT *  FROM `words_for_slps` WHERE `word`
^([bcdfghjklmnpqrstvwxz]|ch|sh|zh|th|wh|ng|qu|wh|tch|ph)
(a|e|i|o|u|aw|ow|ie|ae|oe|oy|oo|uu|y)
([bcdfghjklmnpqrstvwxz]|ch|sh|zh|th|wh|ng|qu|wh|tch|ph){2}
(a|e|i|o|u|aw|ow|ie|ae|oe|oy|oo|uu|y)$

Roxio Toast – Crashes

We’re redoing all of our software so that it works on OSX Lion so that means lots of Toasting. A couple of times I went home without quitting Toast and the next morning it was frozen. Force quitting got out of the app but it wouldn’t launch. I tried removing the preferences files. Still no luck. On two occasions, I reinstalled the app and it would still not open. The only solution I have found is very un-Mac like—reboot the computer. It’s worked the last two times so I think that’s the solution to freezes.

Hybrid Disc Problems with Toast and Director

We’ve been using Toast to burn Hybrid CDs since 1994. When I first purchased the new version I was a bit upset that they took out the ability to burn old-style hybrid CDs. However, they didn’t remove the functionality, they just turned it off. Go into the preferences and enable “Show legacy formats and settings” and it will behave just like it did before. Well, almost. Now it has some really annoying animation, but otherwise it works the same. One other difference was a bit harder to track down and fix.

All of our software current software titles were made with Macromedia Director and with the introduction of OSX Lion they no longer work. The transition to Adobe Director 11.5 has been relatively painless except for some old Flash code in Actionscript 1.0 that hasn’t updated nicely to ActionScript 2.0.

However, when we gave the discs to some people in the office to test they got two errors. When they tried to run program from the disc, an application alert came up telling them “This application requires Adobe Shockwave 11, which can not be found. Click to download it.” If they try to copy it to the hard drive, they get a different error. “The alias “Gamename” cannot be copied to the destination, perhaps because the destination does not support this type of alias.” Our development machines don’t give any errors—even the alias one.

It turns out that the problem is in the way Toast handles (or rather doesn’t handle) aliases in the app bundle.

The app bundle looks like this

Hybrid CD Error

If you follow the aliases you’ll find that
DPLib ==> /Contents/Frameworks/DPLib.framework/Versions/A/DPLib
Resources ==> /Contents/Frameworks/DPLib.framework/Versions/A/Resources

Replace the aliases with the source files, and do the same thing in IMLLib.framework and ProjLib.framework. As near as we can tell the Current alias isn’t necessary and can be deleted from all three locations.

Once you have all your aliases replaces and successfully burned a test CD, make a copy of the Frameworks folder. You can replace the Frameworks folder in new apps with the one that you have working.

The solution was tested on OSX 10.3.9, 10.4.11, 10.5.8, and 10.6.8. We haven’t had access to a Lion machine yet.

Color Depth

We started out making games with Director 4 back when Windows only supported 8 bit palettes and monitors were 640×480. We chose a background color from the Mac Palette that is hex #0066FF. About 5 years ago we updated our movies so that they would fill the whole screen on larger monitors. Most of the backgrounds and menus Flash .swf files. They scale nicely at all resolutions. We had a bunch of backgrounds masks that are solid colors so we just transformed them to 16 bit bitmaps.

We’re updating a bunch of Director movies to D11.5 so that they will run on OSX Lion and our graphic designer noticed that the backgrounds weren’t exactly the right color. It turns out that Director, for its usual inscrutable reasons, didn’t map the Mac Palette color to #0066FF and they ended up being #0063FF instead. Transforming them back to 8 bit and then to 32 bit fixed the problem.

Apple Store App is Now Available

FAA Glossaries is now available on the App Store.

This app is a collection of Glossaries found in FAA publications for pilots. It includes words, terms, and acronyms from seven FAA books: Handbook of Aeronautical Knowledge, Airplane Flying Handbook, Instrument Flying Handbook, Instrument Procedures Handbook, Aircraft Weight and Balance Handbook, Aviation Instructor’s Handbook, and Aviation Weather. It also includes the acronyms from the AIM, the complete Pilot/Controller Glossary, ATC Glossary, and definitions from the FARs—TITLE 14–Aeronautics and Space.

Get FAA Glossaries from the Apple App store!

FAA_Glossaries-First_Day