http://www.perlmonks.org?node_id=231528


in reply to Regex not matching all in DB

Well, I really don't think it has anything to do with your regexes; you say they are working on some cases, and since that is true, they should be working on all cases -- that is, all cases that really do match those regexes.

How closely have you looked at the content of the strings you get back from that database connection? I would suggest that there may be some extra characters in there that aren't visible if you're just using a typical console window or browser to view them. Open an output file -- and use binmode() to make sure nothing gets "interpreted" on output -- and write the offending text before and after the call to tagremover. Then look at it with any hex-mode viewer. It may be that some of those unaltered entities have "invisible" garbage characters thrown in somehow.

One other point, on a different topic:

while ($db->FetchRow()) { ... my $db2 = new Win32::ODBC($connstring) or die $!; ... }
I haven't used ODBC personally (I'm in a solaris/oracle shop), but it strikes me as wrong to be doing this connection thing on every iteration of the "while()" loop. Aren't you using the same database here as in the initial connection? Wouldn't the original connection be persistent and available for further queries/updates until you explicitly close it or exit? (I could be wrong about this, but if the repeated open is unnecessary, removing it could save you a lot of overhead.)

Good luck with the text content.