Skip to main content
Participant
September 24, 2025
Question

Regex not matching uppercase letters

  • September 24, 2025
  • 2 replies
  • 125 views

I'm doing a find/replace using this regex:

([A-Z]{3,4}\s\d{3})

 

It should match patterns like this: INFO 120 or POL 312

 

But is also matched "ered 300" in the string "course numbered 300 or ..." 

 

Shouldn't [A-Z] only match uppercase letters?

    2 replies

    B i r n o u
    Legend
    October 6, 2025

    hello @paul_2273 ,

     

    That’s both normal and not normal at the same time 😉 Your regex is perfectly fine, but if in Dreamweaver the Match case option isn’t checked, the search runs in case-insensitive mode (i). So even [A-Z] will match lowercase letters too.

    So, just make sure to mark Match case, and everything will work exactly as expected!

    Community Expert
    September 25, 2025

    I can't explain why it is picking up "ered" as based on your regex it should not because they are not capital letters to your point. But your match doesn't have a negative lookahead or lookbehind. So because of this, it will look for anywhere there are 3 capital letters, followed by a space, then 3 numbers. Something like this should block out words longer than 3-4 characters ( ([A-Z]{3,4})(?![A-Z])\s\d{3} ) ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookahead_assertion ).