• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Invalid RegEx on @Pattern

 
Bartender
Posts: 1938
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 1938
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 1938
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 1938
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic