• Post Reply Bookmark Topic Watch Topic
  • New Topic

Pattern Matching  RSS feed

 
sony vijay
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

My code actually works. I ran into a small syntax error. I resolved it. I can't figure out how to delete the post so I guess I will let my question stay on this forum.

I am trying to understand how to use Pattern Matcher in Java. Please see my code below:



I expect the following outputs when I call getOutput function like so:
-- For Input: "abc_userid_name", expected output: "abc@userid@name"
-- For Input: "def_userid_name", expected output: "def@userid@name"

But, when I pass abc_userid_name, the above code throws an error i.e. Invalid doc name: abc_userid_name
Please help me fix this.

Thanks,
Sony
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using .*? That means anything except line end, 0 or more times. That will consume the second _
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Why are you using .*? That means anything except line end, 0 or more times. That will consume the second _

Actually, if he did use '.*?', it would work just fine .

Happy New Year.

Winston
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!