Results 1 to 4 of 4
  1. #1
    ravian is offline Senior Member
    Join Date
    Nov 2007
    Posts
    115
    Rep Power
    0

    Default Regular expression for file path

    I need file path to be in the following form:
    C:\dir\filename.exe

    I am unable to define the correct RE. I face problem with slashes. I would appreciate if someone can give the correct pattern.

  2. #2
    roots's Avatar
    roots is offline Moderator
    Join Date
    Jan 2008
    Location
    Dallas
    Posts
    293
    Rep Power
    7

    Default

    Slash is represented by \\ instead of single slash,
    c:\\dir\\filename.exe

    Is this you are talking about ?
    dont worry newbie, we got you covered.

  3. #3
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    8

    Default

    I need the file path to be in the following form
    This sounds like validation to me... try this:
    Java Code:
    ([a-zA-Z]:(\\w+)*\\[a-zA-Z0_9]+)?.exe
    Does this work?
    Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
    Want to voice your opinion on your IDE/Editor of choice? Vote now!
    Got a little Capt'n in you? (drink responsibly)

  4. #4
    tim's Avatar
    tim
    tim is offline Senior Member
    Join Date
    Dec 2007
    Posts
    435
    Rep Power
    7

    Default OS file systems

    Hello ravian

    Not all file systems use the slash for describing directories. It is best to use the File.separator static member instead of the slash. :D
    Eyes dwelling into the past are blind to what lies in the future. Step carefully.

Similar Threads

  1. regular expression for unicode
    By tharhan in forum Advanced Java
    Replies: 0
    Last Post: 04-01-2008, 10:53 PM
  2. Regular expression with Unions
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-09-2008, 12:03 PM
  3. Regular expression with Intersections
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-09-2008, 12:03 PM
  4. I can't find the right regular expression
    By romina in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 05:36 AM
  5. Replies: 5
    Last Post: 07-31-2007, 04:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •