aspose file tools*
The moose likes Groovy and the fly likes Use Groovy to Parse a URL in Which Searching Critiria Are Embedded in the Path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Languages » Groovy
Bookmark "Use Groovy to Parse a URL in Which Searching Critiria Are Embedded in the Path" Watch "Use Groovy to Parse a URL in Which Searching Critiria Are Embedded in the Path" New topic
Author

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

Natalie Kopple
Ranch Hand

Joined: May 06, 2003
Posts: 325
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

Joined: May 06, 2003
Posts: 325
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

Joined: May 06, 2003
Posts: 325
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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Use Groovy to Parse a URL in Which Searching Critiria Are Embedded in the Path
 
Similar Threads
Parsing XML in Groovy
Hotfix Code in tomcat container running groovy application
Performance Issue.
What is Groovy and in which cases we need Groovy?
com.gargoylesoftware.htmlunit.ScriptException: TypeError: is not a function, it is undefined