Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

find  REST like pattern with parameters to determin WS Operation

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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 about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

837 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