Skip to main content
December 7, 2021
Solved

regexmatch error

  • December 7, 2021
  • 2 replies
  • 0 views

Hi All,

I am getting error for pattern  below  

("^[a-z._-@'0-9A-Z]+$")

Error is illegal character range near index 8 . it is near dot.

Please let me know if  any acceptable pattern for below charater. 

thanks

Sushma.

    Best answer by mikes0011

    Just a quick guess here but I assume this might be because of the "-" between "_" and "@" -- per my recollection, inside the [] operators, "-" implies you're defining a range (like "a-z" and "0-9"), but then you have "_-@" which... isn't a range?  If your intent is that "-" is a literally allowed character, you probably need to escape it.

    regexmatch(
      pattern: "^[a-z._\-@'0-9A-Z]+$",
      searchString: "asdf"
    )

    2 replies

    mikes0011
    mikes0011Answer
    Brainy
    December 7, 2021

    Just a quick guess here but I assume this might be because of the "-" between "_" and "@" -- per my recollection, inside the [] operators, "-" implies you're defining a range (like "a-z" and "0-9"), but then you have "_-@" which... isn't a range?  If your intent is that "-" is a literally allowed character, you probably need to escape it.

    regexmatch(
      pattern: "^[a-z._\-@'0-9A-Z]+$",
      searchString: "asdf"
    )

    The Expression Guru
    sushmabAuthor
    December 9, 2021

    Thanks a lot it helped me.