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 2 of 2

Thread: Regex Question

  1. #1
    Junior Member
    Join Date
    Jun 2009
    Posts
    18
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default Regex Question

    I can search for a word in a string with regex as follows:

    PHP Code:
            Pattern p Pattern.compile(regex);
            
    Matcher m p.matcher(toCheck);
            
    flag m.find(); 
    where regex is a string representing the word, and toCheck is the string to check. However, how can I check a string for separated chars? I want to check if a string contains square brackets and curly braces although there will be text between these chars. I know how to do this with indexOf method, but is there a way I can use regex to check for multiple chars in one statement? I was thinking something like "/[+/]+/{+/}" but not having any luck getting it to work


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Regex Question

    All you need to know about regexp

    Regular-Expressions.info - Regex Tutorial, Examples and Reference - Regexp Patterns

    // Json

Similar Threads

  1. [SOLVED] Difference in the code on changing logical operators
    By lotus in forum Loops & Control Statements
    Replies: 3
    Last Post: June 20th, 2009, 03:30 AM
  2. [SOLVED] Java Regular Expressions (regex) Greif
    By username9000 in forum Java SE APIs
    Replies: 4
    Last Post: June 11th, 2009, 05:53 PM
  3. [SOLVED] How to narrow down the range of input in java?
    By big_c in forum What's Wrong With My Code?
    Replies: 5
    Last Post: April 20th, 2009, 11:38 AM
  4. How to show 2D array using combobox and radiobutton?
    By Broken in forum Loops & Control Statements
    Replies: 1
    Last Post: March 10th, 2009, 06:01 AM
  5. Replies: 1
    Last Post: February 28th, 2009, 10:05 PM