Results 1 to 2 of 2
  1. #1
    aruna1 is offline Member
    Join Date
    Mar 2009
    Rep Power

    Default need help to make this regular expression

    I'm trying to make a regular expression to read content of a text file under following restriction. "The text on file can consist only of lowercase English characters 'a' to 'z', the space character ' ' , '\', '{' and '}' "

    can some one help me to make regular expression that can match this kind of content?
    i tried following

    "[a-z]+|\\\\+|\\{+|\\}+" but didn't work


  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power


    It looks like you've been looking at someone else's regexes and tried to club something together without really understanding what each part does. All you need is a single character class containing all valid characters.
    Java Code:
    "[a-z \\\\{}]+"
    There's a great regex tutorial here:
    Regular Expression Tutorial - Learn How to Use Regular Expressions


Similar Threads

  1. Regular Expression Problem
    By daflores in forum Advanced Java
    Replies: 8
    Last Post: 02-10-2009, 06:45 PM
  2. Regular Expression Challange
    By hiklior in forum New To Java
    Replies: 2
    Last Post: 04-24-2008, 05:05 AM
  3. Regular expression with Unions
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-09-2008, 12:03 PM
  4. Regular expression with Intersections
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-09-2008, 12:03 PM
  5. 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

Posting Permissions

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