In the following example, I have a list of filenames in a text file. However, some of the lines are missing the file extensions:

Sample data:

  1. 10000187 - How to grow Papaver commutatum from seeds
  2. 20001075 - Cultivation of the Meconopsis betonicifolia
  3. 30000566 - Looking after a Hoya carnosa during winter.pdf
  4. 40000873 - Growing Bhoot Jholokia chillies from seeds.docx
  5. 50000097 - Pests and diseases affecting alliums.msg

Using the following RegEx, I can find the lines that DO contain extensions, thus:

Search "\b(?<=([.][a-z]{3})$)|(?<=([.][a-z]{4})$)\b" (3 hits in 1 file)

Results:

  • Line 3: 30000566 - Looking after a Hoya carnosa during winter.pdf
  • Line 4: 40000873 - Growing Bhoot Jholokia chillies from seeds.docx
  • Line 5: 50000097 - Pests and diseases affecting alliums.msg

However, I need to find the lines that DON'T contain the file extensions (as in a Negative match).

Is there a simple way of doing this, rather than compare the results with the original list and then identify the ones that don't match during the compare?

I'm a newcomer to RegEx and still learning, so any help would be greatly appreciated

Thanks in advance

0 Answers