Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use Groovy to Parse a URL in Which Searching Critiria Are Embedded in the Path

 
Natalie Kopple
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am completely new to the Groovy.

thanks for your time and help in advance.

I am using soapUI mock service and trying to write a Groovy script. The request query URL I receive looks like:

http://{host}:{port}/readwrapper/historicalData/medicalHistory/STR/888888_2.16.840.1.113883.3.42.10012.100001.206_h0102a3727570b14038b349136f2a5fd58e0102

and the search criteria are embedded in the above URL. The search criteria that I am trying to extract from this URL are
A. 2.16.840.1.113883.3.42.10012.100001.206 which is the communityID
B. h0102a3727570b14038b349136f2a5fd58e0102 which is the document ID

All I am able to code in Groovy is:

and I do not know how to proceed further. Please help.
 
Natalie Kopple
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that there is a solution but I am still unclear about the index of the "tokenize()" method.


The long string 888888_2.16.840.1.113883.3.42.10012.100001.206_h0102a3727570b14038b349136f2a5fd58e0102 that is tokenized, there are two delimiters; i.e., '_' and three parts.

I think if I want the last part, I should do:


What if I want the first part and the second part? Which indexes are they? Thank you very much.

 
Natalie Kopple
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that there is a solution but I am still unclear about the index of the "tokenize()" method.


The long string 888888_2.16.840.1.113883.3.42.10012.100001.206_h0102a3727570b14038b349136f2a5fd58e0102 that is tokenized, there are two delimiters; i.e., '_' and three parts.

I think if I want the last part, I should do:


What if I want the first part and the second part? Which indexes are they? Is the first part parts[0] and the middle part parts[1]? Thank you very much.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic