Question: How do I format a reg.exp. to ignore matching text in a search. We have documents formatted like this:

> 
> ProductType\_[dimensions][density].pdf
> 
> 
> 

So in a typical folder, the file list would be:

```
RN_HG_HighDry_001x450.pdf
RN_HG_HighDry_001x895.pdf
RN_HG_HighDry_002x136.pdf
RN_HG_HighDry_002x887.pdf
RN_HG_HighDry_FULL_5.pdf
RN_HG_HighDry_FULL2.pdf

```

I can select the documents that contain the plastic sizes using:

`(\d{3}x\d{3}\.pdf$)`

(we specify the pdf as sometimes the folders contain other documents on no relevance)

But I want to create an expression to select the pdf's without a plastic size (but with/without a density size), so in English what I want to do is select all .pdf files, except those that include the string (three numbers, letter 'x', three numbers).

I have tried `([^\d{3}x\d{3}]\d\.pdf$)` , I think the `[^` at the start means NOT, but it's not working. I have also tried all sorts of other permutation but to no avail. I'll be dreaming about Reg.Exps tonight as I have been playing about with this for so long!

Answer: 
With the square brackets `[]` you are creating a character class, that means such a class matches all character that are inside the class. And you are right a character class starting with `^` means NOT, but in a different sense. It means match any character but not those in the class.

`[^\d{3}x\d{3}]` will match any character ,but not a digit, not `{`, not `}` and not `x`

If your language supports lookahead assertions you can do this

```
(?!^.*\d{3}x\d{3})\d\.pdf$

```

See it [here at Regexr](http://regexr.com?2v9eg)

`(?!^.*\d{3}x\d{3})` is a negative lookahead assertion, it will check the whole string and if it doesn't find `\d{3}x\d{3}` the assertion will be true and it tries to match for `\d\.pdf$`
If you don't have support for negative lookaheads, you will basically have to enumerate the patterns you do want to catch. For your particular application, why don't you just exclude the ones you know how to match, and keep the rest? You don't mention which programming language or matching program you are using, but something along the lines of

```
vnix$ egrep -v '_[0-9]{3}x[0-9]{3}\.pdf$' listoffilenames | grep '\.pdf$'

```

From the limited set of examples you provide, a positive regex might look something like

```
vnix$ egrep '[^0-9][0-9]\.pdf$' listoffilenames

```

would work, but I expect you want a regex with better coverage to catch files which do not have any number at all before the .pdf extension, for example. A slightly broader pattern might be

```
vnix$ egrep '([^0-9]|[^0-9][0-9]{1,2}|[^x][0-9]{3})\.pdf$' listoffilenames

```

Please follow up with a more detailed specification of your needs if you still need help.