Solved

find  REST like pattern with parameters to determin WS Operation

Posted on 2007-11-13
2
209 Views
Last Modified: 2012-08-13
Using Java (preferred solution)

built some SOAP services but providing a REST interface (just servlets) and need a way to use regex to parse out the urls.  the basic pattern is

get all things:
http://blahblah/things
get all things with some criteria
http://blahblah/things?id=value1&type=value2

getcertain things by name
http://blahblah/things/name

the regex pattern i was using seems to always give me the things/name and i really want an easy way to say
things
things?...
things/

but not things/something
which may or may not have parameters

I am looking to validate parameters once i know which operation i want to deal with.  the idea of the above url pattern was that some parameters are required or not allowed for some of the patterns so i don't want the regex to care about the parameter but can't use $ (end of line) b/c parameters might be presenent

i kept trying "things[/]?" and other permutations
0
Comment
Question by:jonasmit
  • 2
2 Comments
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 250 total points
ID: 20275776
jonasmit,

Maybe I am oversimplifying this or misunderstanding something but what about ...

things$|things\?|things/

To use it in Java you will probably need to add some slashes.  Let me know if you have a question using it.  That expression will give you what you want if I understood you correctly.

Let me know if you have any questions or need more information.

b0lsc0tt
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20275948
Great!  I'm glad it did what you needed and I could help.  Thanks for the fun question, the grade and the points.

bol
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
xampp tool 12 51
JavaScript and Regular Expressions - How to implement date validation? 7 62
Configure a Bean in an XML file 4 32
how to install java on RHEL image on EC2 4 28
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question