Solved

find  REST like pattern with parameters to determin WS Operation

Posted on 2007-11-13
2
208 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now