...

View Full Version : Regex in dreamweaver



snarf1974
08-26-2009, 02:18 PM
Hi all,

I'm trying to use regex in dreamweaver to remove certain pdf file sizes across a large site.

I need to delete all digits along with the squared brackets. Anything under 2MB also needs to be deleted. Obviously the 'MB' and 'KB' also need to be deleted (but only if the file size is below 2MB).

Here's an example:


blah blah blah [2.5MB]

blah blah blah [1.4MB]

blah blah blah [18KB]

blah blah blah [1MB]

blah blah blah [100KB]

blah blah blah [52KB]

blah blah blah [2MB]

I've been using this regex:

/\d+(KB|MB)/g
...which is okay, but I'm only starting out with regex, and would really like to also remove file sizes under 2MB, as explained above.

Any help would be greatly appreciated.

Many Thanks

:)

oracleguy
08-26-2009, 04:12 PM
\[(\d+(\.\d+){0,1}KB|1(\.\d+){0,1}MB)\]

Basically you need to look for all cases of KB and then the case where you have anything in the one megabyte range. This of course assumes there isn't anything like 0.83MB, I assume you'd write that as 830KB.

Does that make sense?

snarf1974
08-26-2009, 05:09 PM
Thank you OracleGuy!!

You have saved the day, mucho mucho appreciated. Yes, you're right in your assumption, there isn't anything like 0.83MB, it'd be 830KB.

:-)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum