• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Pattern Matching

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79508
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you using .*? That means anything except line end, 0 or more times. That will consume the second _
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic