-1

I have a String in Java, something like this -

{elementId:'pagination',locale:'en',activePage:'1',items:'-10',maxButtons:'5'}

I need the numbers without the quotes

{elementId:'pagination',locale:'en',activePage: 1, items: -10, maxButtons:5}

Tried

 replaceAll("\\d+", "$0") or 
 replaceAll("[0-9]", "$0")

But it returns me number with quotes.

Is there a way to remove these quotes for numbers?

User
  • 35
  • 1
  • 7

1 Answers1

0

If {elementId:'pagination',locale:'en',activePage:'1',items:'-10',maxButtons:'5'} is a string as you've said, you could use the String.replace method. As such: foo.replace("'",""); this method returns a string with all instances of ' replaced.

blankpanda
  • 84
  • 2
  • OP wants to the quotes only for numbers not throughout the string – Harish Barma Aug 03 '17 at 19:55
  • Thanks for your answer, but I need elementId:'pagination',locale:'en',activePage: 1,items:-10,maxButtons: 5 so replacing all " ' " will also replace the text values for elementId:'pagination',locale:'en'. I don't want that – User Aug 03 '17 at 19:56