June 25th, 2013, 07:27 PM
Simple regex to pull value from JSON payload.
First let me apologize for being a total newbiew to regex.
I am sure this is really simple, and any help is greatly appreciated!
The value I am looking to extract exists on its own line, and is always in the same format, so should be pretty straight forward.
This is how the line of data looks in the JSON file:
I need the number value only.
June 25th, 2013, 07:51 PM
Matcher group 1 contains the value you need.
June 26th, 2013, 01:06 AM
Thank you for the reply, but I tried this in several different testers and it did not produce any matches.
Originally Posted by noobie1000
I modified what you had and was able to match the Entire string using:
But that is NOT what I need... I need the match to come back ONLY as 15806 in this example, obviously that number can be anything between 00000-99999.
Does some kind of search/replace need to happen to return only the 15806 value in this instance?
June 26th, 2013, 12:36 PM
You need the parens to capture the number.
Check on how to access the capture in your programming language.
June 26th, 2013, 03:18 PM
Will the regex madness ever stop?
JSON is a common data format. It's well-defined, well-understood and widely used. This means that every mainstream programming language has a JSON parser. It doesn't matter whether you use PHP, Perl, C or this Microsoft stuff: Your language has a parser for JSON. Either built-in or provided by a third-party library.
Use it, for heaven's sake! Parse the JSON file, fetch your data and be happy. It's quick, it's simple, and it's robust.
There's absolutely no reason whatsoever to scrape the data with some stupid regex. Why would you do that? Do you love the cryptic syntax so much? Do you feel bad about using premade solutions? Don't. Programming is all about choosing the right tool. Only fools create everything from ground up.
June 27th, 2013, 01:39 AM
The madness will most certainly stop as soon as the pompous megalomaniacs with nothing to contribute and excessive time on their hands stop trolling.
Originally Posted by Jacques1
If you have ever worked in IT and had a POS 3rd party software thrown at you by some disillusioned, disconnected blowhard bureaucrat, such as yourself, you might actually understand why were forced into using less than desirable means to solve a problem.
In the meantime while we wait for the regex madness to stop, and trolls to stop trolling may I kindly suggest you GFY...
Comments on this post
June 27th, 2013, 05:21 AM
... says the guy who can't put together a single regex.
Originally Posted by guht
Yeah, good for you, amateur.