Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 19th, 2006, 05:08 AM
Authorized User
 
Join Date: Jul 2006
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default java regular expression

Hi everyone,

I`m working in a java program that has to check the sintax of an url.

This sintax is as follows:

       {rmt or fos or win or los or}/content.xml

ie. one of this words(rmt,fos,win,..) slash and the word content.xml

I'm using the function string.matches(string regex) and I having problems in finding the correct regular expression for this url.

This is the regular exp I thought of and which doesnt work:

url.matches("[fos|rmt|inc|inf|los|res|all]//[content.xml]")

Thanks for the help.

Tomi.

 
Old September 26th, 2006, 02:32 PM
Friend of Wrox
 
Join Date: Dec 2003
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Those square brackets enclose a character class.

How about:

url.matches("^(fos|rmt|inc|inf|los|res|all)?//content.xml$")

Should work, but not tested. BTW the ^ and $ mean start and end of the string.

HTH

--
Don't Stand on your head - you'll get footprints in your hair
                                           http://charlieharvey.org.uk
                                              http://charlieharvey.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular expression C# radhakrishnan1976 General .NET 1 February 19th, 2006 01:11 AM
Regular Expression Help anshul PHP How-To 4 December 8th, 2004 05:19 AM
regular expression vohra_vikas2004 ADO.NET 3 November 18th, 2004 09:59 PM
regular expression Moharo Pro PHP 3 April 30th, 2004 04:44 AM
Regular Expression Help Hadware .NET Web Services 3 November 4th, 2003 10:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.