AutoCAD Find and Replace Wildcards are broken

I found this bug when doing a find and replace on some IP addresses in an AutoCAD drawing. I was using it as a template for a new drawing so I wanted to reset the IP addresses to a default to avoid duplicating the existing values.  Here is what I started with …

so far, so good

So, I fired up my trusty AutoCAD Find and Replace window, like thus…

AutoCAD Find and Replace window. Finding *.*.*.* and replacing with xxx.xxx.xxx.xxx

… and then selected the block in question & hit Replace All. I got this …

Not the desired result. Huh?

That ain’t right. I tried the same thing in Excel. From this …

Same procedure in Excel, before

… using the same Find and Replacement text …

Excel Find and Replace Window

… and I got this …

Replacement in Excel - ah, that's better

That’s more like it. To paraphrase Sesame Steet, “One of these things does not work like the other ones.”

So, why are they different?

Initially, I thought the difference was that Excel’s search is greedy and AutoCAD’s search is an inconsistent mix of lazy and greedy. Here is an explanation of the difference between lazy and greedy text searching, as it pertains to using Regular Expressions. In a nutshell, a lazy search reckons it is done when it has found the bare minimum it needs to satisfy the requirements of the search. The * wildcard I used in the find section will match one or more of any character. A lazy search reckons it’s done when it matches one character, a greedy search will keep matching characters until it eventually runs our of ones that match the search string. In Excel’s  case it stops when it gets to a dot, in AutoCAD it did that with the middle but not at the beginning and the end.

The more I looked at it the more I realised that isn’t right. AutoCAD had actually ignored the first and last wildcards in the search. Instead of looking for *.*.*.* it has looked for .*.*. As Occam’s Razor inevitably predicts, it’s not as complex as I first thought – it’s simply somewhat broken.

I’d say that’s a bug, folks. I guess I’ll be using ol’ faithful Excel for that find and replace exercise. Well, actually, it’s not that bad – the ? wildcard still works so I can use ???.???.???.??? in various number of ?’s to (eventually) get there. It’s still a bug, though.

Be Sociable, Share!

3 responses to “AutoCAD Find and Replace Wildcards are broken”

  1. Rollin Laird

    Try a .NET add-on called RegexReplace shareware program from Tumpliner.com. It will work with all Regular Expressions that are valid over .NET.

Leave a Reply

Notify me of followup comments via e-mail. You can also subscribe without commenting.

I invite you to discuss your thoughts here. By contributing to these discussions you are helping to make the Internet (and hopefully this site) a forum for open and intelligent discussion. ok, now for the Fine print ... by submitting your comment here you grant CAD bloke a perpetual license to reproduce your words, name and web site in attribution. Personal attacks & unwarranted profanity won't be tolerated. You may edit your comment within four hours of posting it.