• 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

Another regex question with { , Curly braces

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I need to filter out regex from my string when ever i encounter for example
{0} or {1} so on to {100}.

I got regex like '\{\\d*\{ ' and '{[0-9]}'. But none are working. Please help. Kind of urgent.

 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's kind of no such thing as "urgent" here.

What do you know about regular expressions? Is { a meta-character? How many \\ are you using to escape it? do you need \\ if you are in a String?
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A tip on regular expressions: start smaller. Can you match the following in order?

  • {
  • a number from 0-100
  • }
  • the whole thing


  • Which one gives you trouble. What did you try for it?
     
    paddy Mahadeva Iyer
    Ranch Hand
    Posts: 63
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Campbell, Sorry for that 'urgent' comment. but was in a desperate situation then. Will be careful in future.

    Hi jeanne, I will try that and get back.

    Hi All, Actually I tried constructing the regular expression using the online expression generators. Some of the expressions that were working there was not when it came to the Java Pattern class. Don't know Why.

    Will get back. Please do give me your suggestions.
     
    paddy Mahadeva Iyer
    Ranch Hand
    Posts: 63
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi guyz,

    worked around this problem without regex since could not find a solution.

    Thanks
    Paddy
     
    Ranch Hand
    Posts: 43
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    hey, paddy Mahadeva Iyer
    can give some more details about your problem......
    what you want retrive...
     
    Campbell Ritchie
    Marshal
    Posts: 79153
    377
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Agree. Please tell us what you have achieved so far.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic