Jump to content

Extending existing StringRegExp query


Recommended Posts

Okay, last beg for help for a while I promise.

Having finally got my script searching for files, I need to exclude a few I don't want to process.

The function so far uses StringRegExp to decide whether to include the file in the array or not, with the pattern of "(?i)\A(?!.*?[.]db$|.*?[.]ini$|.*?[.]log$)" which might be wrong, but seems to work on excluding .ini, .db and .log, so I might have actually got it right.

Depending on options I may also want to skip files with *(M).inf,*(U).inf, and *(V).inf. A simple "\(M\)" pattern seems to work alone, but not added to the original pattern. So could one of you please beat it into one search pattern for me? Or am I going to have to rewrite the function to do multiple checks? Which I really don't want to do.

My brain simply doesn't understand StringRegExp and it's friends, so I'm hoping it's painfully simple for one of you more capable folks like everything else I mange to get stuck on.

Thanks in advance to whoever comes to my rescue ;)

Link to comment
Share on other sites

Try "^.*(\.(ini|db|log)|\((M|U|V)\)\.inf)$"

I'm not sure exactly what you want though, but I recommend GeoSofts PCRE Toolkit (available in his signature) for testing this sort of stuff.

Edit: Just to explain:

^ .* ( \. ( ini | db | log ) | \( ( M | U | V ) \) \.inf ) $

so it matches up to either:

  • a dot followed by ( 'ini' or 'db' or 'log' )
  • An opening bracket followed by an ('M' or 'U' or 'V') and then a ').inf'
Edited by Mat
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...