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: illegal state exception from regex

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default illegal state exception from regex

    If body is the string "{oli22} potatoes are cool" anyone know why when this code returns an illegal state exception: no match found when either of the group(1) begin to look for their patterns. Thanks for you help.


    private static final Pattern BRACE_END = Pattern.compile(".*\\}");
    private static final Pattern EGGS = Pattern.compile("\\{(.*)\\}");
    private static final Pattern BACON = Pattern.compile("\\}(.*)");

    public class jibbles {

    public boolean workdamnyou(String body, Data data){
    if (body.startsWith("{")){
    if (BRACE_END.matcher(body).lookingAt()){
    if (EGGS.matcher(body).find()){
    eggs = EGGS.matcher(body).group(1);
    }
    if (BACON.matcher(body).find()){
    bacon = BACON.matcher(body).group(1);
    }
    }
    }
    }


  2. #2
    Junior Member
    Join Date
    Sep 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: illegal state exception from regex

    I switched to using indexOf and substring. everything is hunky-dory now.

Similar Threads

  1. Replies: 0
    Last Post: March 13th, 2013, 01:32 AM
  2. State UML Diagram
    By calebite207 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 18th, 2012, 12:30 PM
  3. Why can't I state the values of the constructor??
    By jean28 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 27th, 2012, 12:25 AM
  4. Exception in thread "main" java.lang.IllegalArgumentException: PWC6309: Illegal compi
    By nagaraj200788@gmail.com in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: July 18th, 2012, 05:45 PM
  5. [SOLVED] I need help with saving state data.
    By JonLane in forum Collections and Generics
    Replies: 6
    Last Post: February 27th, 2012, 03:48 AM

Tags for this Thread