. in regular expression shows me compiler error

when i use . regular expression in @pattern it shows me compiler error i have provided code below

@Pattern(regexp="[a-zA-Z]+.[a-zA-Z]+")

for more clearance check out this link

but it works fine in RegExp tester

2
Leave a Reply

avatar
2 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Jason Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Jason
Guest

A single has special meaning within the Java language, so needs to be ‘escaped’ within the String. We escape it by prefixing with , so you need to write \. instead. More information can be found the official Java regex tutorial

Jason
Guest

You need to escape it the backward slash: \