Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Another regex question with { , Curly braces  RSS feed

 
paddy Mahadeva Iyer
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • 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.

 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • 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?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37507
552
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
    • 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
    • Quote
    • Report post to moderator
    Hi guyz,

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

    Thanks
    Paddy
     
    pradipta kumar rout
    Ranch Hand
    Posts: 43
    • Mark post as helpful
    • send pies
    • 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: 56578
    172
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Agree. Please tell us what you have achieved so far.
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!