Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Help with regex pattern

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help with regex pattern

    Community,

    I need some help developing a regex pattern that will do the following remove all illegal characters from a file name.

    These characters include:
    • #
    • <
    • >
    • %
    • {
    • }
    • |
    • \
    • ^
    • ~
    • [
    • ]
    • `
    • ;
    • /
    • ?
    • :
    • @
    • =
    • &
    • $


    All other alphanumeric and symbol characters are valid and should be left as is.

    Any help would be greatly appreciated, thanks in advance.


  2. #2
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: Help with regex pattern


  3. #3
    Junior Member
    Join Date
    Jul 2010
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help with regex pattern

    Daryl,

    Why does that matter?

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Help with regex pattern

    Why should anyone here waste time answering a question that is answered already on another forum. How does anyone here know if the question has been answered? If the OP is considerate enough to include a link to his other posts, then we can check before spending time on the question.

  5. #5
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Help with regex pattern

    Use a character class along with the replaceAll function of String. See Character Classes (The Java™ Tutorials > Essential Classes > Regular Expressions)

Similar Threads

  1. a new pattern with a new architecture
    By mcgrow in forum Web Frameworks
    Replies: 0
    Last Post: August 4th, 2010, 02:28 PM
  2. Stuck -- Loop Pattern
    By CodeNewb in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 11th, 2010, 03:02 AM
  3. Urgent need a java regex pattern
    By mallikarjun_sg in forum Java Theory & Questions
    Replies: 1
    Last Post: May 6th, 2010, 05:51 AM
  4. [SOLVED] Need Regex for a pattern
    By mallikarjun_sg in forum Java Theory & Questions
    Replies: 7
    Last Post: May 5th, 2010, 02:06 AM
  5. url pattern issue - please help me...
    By bharathik in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: November 9th, 2009, 04:28 AM