• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Invalid RegEx on @Pattern

 
Mike London
Ranch Hand
Posts: 1190
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Eclipse, I get an invalid escape sequence from the pattern below to validate an email address box.



The error is referring to the "\." below.

However, I can find this same regular expression in several places on the Internet (and in Spring books).

What's wrong here?

Thanks.

mike
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does it need to be escapes, because in there it thinks the \ is an escape? so Use "\\"

Or is it the other way around where you put it in there as an escape and it doesn't need it?

Just guessing here.

Mark
 
Mike London
Ranch Hand
Posts: 1190
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark Spritzler wrote:Does it need to be escapes, because in there it thinks the \ is an escape? so Use "\\"

Or is it the other way around where you put it in there as an escape and it doesn't need it?

Just guessing here.

Mark


Hi Mark,

As I understand it, since "." is a RegEx operator, to use it as a regular period (.), as in validating the "." before the domain, you have to escape it with a "\".

If you used two \ marks, then you're escaping the escape character itself.

Thanks,

mike

 
Mike London
Ranch Hand
Posts: 1190
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike London wrote:
Mark Spritzler wrote:Does it need to be escapes, because in there it thinks the \ is an escape? so Use "\\"

Or is it the other way around where you put it in there as an escape and it doesn't need it?

Just guessing here.

Mark


Hi Mark,

As I understand it, since "." is a RegEx operator, to use it as a regular period (.), as in validating the "." before the domain, you have to escape it with a "\".

If you used two \ marks, then you're escaping the escape character itself.

This email validation code came right out of "Spring 3 in Action".

Thanks,

mike

 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike London wrote:
Mark Spritzler wrote:Does it need to be escapes, because in there it thinks the \ is an escape? so Use "\\"

Or is it the other way around where you put it in there as an escape and it doesn't need it?

Just guessing here.

Mark


Hi Mark,

As I understand it, since "." is a RegEx operator, to use it as a regular period (.), as in validating the "." before the domain, you have to escape it with a "\".

If you used two \ marks, then you're escaping the escape character itself.

Thanks,

mike



OK, Just checking. and I hate Regex because I don't understand it and I am awful at it. ;)

Mark
 
Mike London
Ranch Hand
Posts: 1190
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
LOL

Well, now I'm wondering if it's a bug somewhere.

I'm following up with the IDE company as well.

Thanks Mark.

mike
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic