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: Replace bracket

  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Replace bracket

    Hi guys, i have this text:
    com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: 
    Cannot add or update a child row: a foreign key constraint fails 
    (`sita4`.`control`, CONSTRAINT `reffinalit` FOREIGN KEY 
    (`finalit`) REFERENCES `finalit` (`cod`) ON DELETE NO ACTION ON UPDATE NO ACTION)

    and i want take the field that have send foreign key in this case "finalit", i have make this code:
    [B]int beginIndex = msgerror[0].indexOf("FOREIGN KEY");
    int endIndex = msgerror[0].indexOf("REFERENCES");
    String field = msgerror[0].substring(beginIndex,endIndex);
    field = field.replaceAll("FOREIGN KEY", "");
    field = field.replaceAll(" *\\(`\\d+`\\)*", ""); \\this not work
    and field is = ('finalit')[/B]
    why replaceall not work on bracket?
    Thanks.


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

    Default Re: Replace bracket

    field = field.replaceAll(" *\\(`\\d+`\\)*", ""); \\this not work

    Replace the above line with below code

    field = field.replaceAll("[ \\(\\)\'\\`]", "");

Similar Threads

  1. Looking to replace email msgs with........... something else.
    By paulmac1968 in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: June 4th, 2013, 12:06 PM
  2. [SOLVED] to replace a word in file
    By shenaz in forum What's Wrong With My Code?
    Replies: 20
    Last Post: March 21st, 2013, 01:53 PM
  3. Using the replace method?
    By jean28 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 22nd, 2012, 04:17 PM
  4. [SOLVED] Bracket placement issues
    By fride360 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 14th, 2011, 05:08 AM
  5. [SOLVED] Replace Phrase in String
    By aussiemcgr in forum Java Theory & Questions
    Replies: 2
    Last Post: October 18th, 2010, 12:10 PM

Tags for this Thread