0

i have this JSON (at the link), and i need to remove some strings from it, i'm a starter at regular expressions so i would like to know how to select any numbers as i put on the Regex:

http://bit.ly/qu8t4b

My pattern its that:

"[0-9]": {

But the pattern using 0-9 just give me 1,2,3,4,5,6,7,8,9 but it doesn't cover the number 12, 100, 234, and etc... someone could help me here?

NullUserException
  • 83,810
  • 28
  • 209
  • 234
Wallysson Nunes
  • 760
  • 6
  • 16
  • Don't re-invent the wheel. Just use a JSON parser. In general, you can't parse using regexes a syntax with arbitrary balanced parenthesis-like construct, such as HTML or JSON. See this SO discussion: http://stackoverflow.com/questions/1732348/ Also, don't write a JSON data by hand by yourself. Instead, construct an array or hash or whatever in your programming language, and use JSON emitter to convert it to JSON. That way you don't face a malformed JSON, ever. – Yuji Aug 31 '11 at 03:16
  • i agreed with you, but thats the way that i found to resolve an bug that i treied all the day, and its the way i found, i spent too many time trying to solve it. if you wanna to see it its here: http://stackoverflow.com/questions/7248287/needing-help-with-json-problems well, i will try to make it at the right way, but not today anymore, im tired with it! – Wallysson Nunes Aug 31 '11 at 03:28

1 Answers1

2

I think what you are wanting is this:

"[0-9]+"

which means "the numbers zero through nine, repeated one or more times".

This allows trailing zeroes, which may be what you want, but you might prefer this instead:

"[1-9][0-9]*"

which means "a digit from one to nine, followed by a digit from zero to nine, repeated zero or more times".

Peter Olson
  • 139,199
  • 49
  • 202
  • 242
  • Oh man, thanks, i tried to use "[1-9][0-9]" but i didn't know the '*' character... really thanks! I tryed to accept your answer, but the stackoverflow wanna to me wait 6min's... :D – Wallysson Nunes Aug 31 '11 at 03:20