-2

I am trying to find a regex that can match the word "Model" or "model" or "MODEL" - it should not match "oneModel" or any word that has model in it.

^([model]{5,10})$

I cannot find an example for this, I am trying to validate a text field that has to be inside ^([a-zA-Z0-9]{5,10})$ as part of this plugin's requirement.

Rain Man
  • 1,163
  • 2
  • 16
  • 49

2 Answers2

0

You need to use the i flag (read more here) for regex to ignore case

using your noted regex /^([model]{5,10})$/i

string.match("^([model]{5,10})$", "i")

if you want ONLY model then you only need /^model$/i

that will match model / Model / MODEL / mOdeL

toms
  • 515
  • 6
  • 23
0

What you looking for may vary depending on what you are looking for. For example if you are looking for this specific word in a full text:

/\bmodel\b/i

this will return true in this text:

this is a MoDel // return true
this is not oneModelTwo // return false

You can test all of your regex (with full explanation of what does what) on this site : regex 101

Joey Peau
  • 51
  • 4