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: 1028
The first one covers an optional blank " ?" between the optional "hot" and donuts.

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: 1028
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"
Vivek Alampally
Ranch Hand

Joined: Jul 10, 2008
Posts: 65
Ok I got it. Thank you so much.
 
 
subject: Regular expression pattern
 
Threads others viewed
Doubt on Regular Expression
How to check whether name of the File is in a Specifi format??
How can I add error handling facilities to this code?
Alphabets only valitation
Need help on Unique Javascript validation
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture