Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2008
    Location
    Liverpool
    Posts
    53
    Thanks
    37
    Thanked 0 Times in 0 Posts

    Question Regex in dreamweaver

    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:
    Code:
    /\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


  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Code:
    \[(\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?
    OracleGuy

  • Users who have thanked oracleguy for this post:

    snarf1974 (08-26-2009)

  • #3
    New Coder
    Join Date
    Aug 2008
    Location
    Liverpool
    Posts
    53
    Thanks
    37
    Thanked 0 Times in 0 Posts
    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.

    :-)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •