15,000 Jobs Available in:
Java, ASP, C#, PHP, SQL, SAP, MySQL and many more.
- Class Quick -
The moose likes HTML, CSS and JavaScript and the fly likes Regular expression pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Regular expression pattern" Watch "Regular expression pattern" New topic
Author

Regular expression pattern

Vivek Alampally
Ranch Hand

Joined: Jul 10, 2008
Posts: 65
Hi

What does the regular expression
/(hot)? ?donuts/ mean?

How is it different from /(hot)? donuts/ ?

Thanks
Vivek.
Chris Baron
Ranch Hand

Joined: Mar 21, 2003
Posts: 1015
The first one covers an optional blank " ?" between the optional "hot" and donuts.

This message was edited 1 time. Last update was at by Chris Baron

Vivek Alampally
Ranch Hand

Joined: Jul 10, 2008
Posts: 65
Thanks Chris for your prompt reply. But i didnt get what you are trying to say. Can you please give me an example illustrating the difference between two regular expressions?
Chris Baron
Ranch Hand

Joined: Mar 21, 2003
Posts: 1015
Hi Vivek,
i haven't testet it, but it looks like

/(hot)? ?donuts/ finds "hot donuts", "hotdonuts", " donuts" and "donuts",
/(hot)? donuts/ finds "hot donuts" and " donuts"

This message was edited 1 time. Last update was at by Chris Baron

Vivek Alampally
Ranch Hand

Joined: Jul 10, 2008
Posts: 65
Ok I got it. Thank you so much.
 
 
subject: Regular expression pattern
 
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com