The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> Regex Programming
|
Regex to extract time slot
Discuss Regex to extract time slot in the Regex Programming forum on Dev Shed. Regex to extract time slot Regular expressions forum covering PCRE and POSIX techniques, practices, and standards. Regular expressions help shorten coding time by providing the ability to compact many lines of code into one string.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

June 6th, 2012, 08:41 PM
|
|
Registered User
|
|
Join Date: Jun 2012
Posts: 7
Time spent in forums: 58 m 30 sec
Reputation Power: 0
|
|
|
Regex to extract time slot
Hi
I am using JMeter to create a performance script for an insurance web app that creates repair jobs for automotive claims. The following text is what is returned from a call to get the free time slots for the repair job ..
{"7":{"45":0,"30":0},"8":{"45":0,"30":0,"15":1,"00":1},"9":{"45":0,"30":1,"15":1,"00":1},"10":{"45":0,"30":1,"15":1,"00":1}}
A '1' against the minute time indicates that it is free. I need to extract the first hour that has a free time slot. In this case it will be '8' as hour 7 does not have any free slots as there is a '0' against both slots 7:45 and 7:30. For hour 8 both slots 8:15 and 8:00 are free. I know I can use the following regex to extract the minute value .."(\d{2})":1..but not sure how to extract the hour time slot.
Any help would be very much appreciated.
Thanks.
Tam.
|

June 6th, 2012, 09:48 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
|
That's JSON. There are ways of dealing with it that are much better than regular expressions.
What are you using to do the AJAX?
|

June 6th, 2012, 10:18 PM
|
|
Registered User
|
|
Join Date: Jun 2012
Posts: 7
Time spent in forums: 58 m 30 sec
Reputation Power: 0
|
|
|
Hi requinx
Thanks for the reply. Sorry I don't understand your question. I have used JMeter to record the test scenario and am now trying to create a test script for this. I need to make the script smart enough to find a free slot, as the slot that was selected in the recording is now no longer free.
Thanks.
Tam.
|

June 7th, 2012, 01:49 AM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
|
I'll rephrase:
You say the text is "returned from a call"... What kind of code is doing the calling? What programming language?
|

June 7th, 2012, 04:39 AM
|
|
Registered User
|
|
Join Date: Jun 2012
Posts: 7
Time spent in forums: 58 m 30 sec
Reputation Power: 0
|
|
|
I'm pretty sure its Java but I'm not 100% on that. I'll find out when Im back at work tomorrow. How do you propose I extract the info from the response to JMeter if not using a regex extraction?
Thanks.
|

June 7th, 2012, 12:24 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
Quote: | Originally Posted by tamnor How do you propose I extract the info from the response to JMeter if not using a regex extraction? |
By using something which can decode JSON. Surprisingly it doesn't seem like there's anything built-in, but json.org lists a bunch of things you can use at the bottom of their homepage.
|

June 7th, 2012, 03:57 PM
|
|
Registered User
|
|
Join Date: Jun 2012
Posts: 7
Time spent in forums: 58 m 30 sec
Reputation Power: 0
|
|
|
Ok. Thanks for the advice. It's definitely Java that the app is written in. I might have a look at some JMeter forums and see if I can find something.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|