Results 1 to 4 of 4

Thread: [java] string.replace

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default [java] string.replace

    Hello,
    is there any change, having a String to replace within it all occurence of "[" and "]" ?
    This works
    Qt Code:
    1. mystring = mystring.replace("[", "") ;
    2. mystring = mystring.replace("]", "") ;
    To copy to clipboard, switch view to plain text mode 
    but I hope there is the way to do it in one shot; is it there?
    thanks.
    Regards

  2. #2
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    1

    Default Re: [java] string.replace

    Yes. Use regular expression.

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [java] string.replace

    Not exactly..but these statements can do -
    mystring.replace("[","").replace("]","");
    mystring.remove("[").remove("]");

  4. #4
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    1

    Default Re: [java] string.replace

    These codes work for me.

    Qt Code:
    1. String mystring = "123[56]";
    2. mystring = mystring.replaceAll("[\\[\\]]", "");
    3. System.out.println(mystring);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. std:string how to change into system:string?
    By yunpeng880 in forum Qt Programming
    Replies: 1
    Last Post: 14th April 2009, 08:51
  2. [java] manipulate a string
    By mickey in forum General Programming
    Replies: 5
    Last Post: 10th July 2008, 20:22
  3. replace string in QList<QStringList>
    By estanisgeyer in forum Qt Programming
    Replies: 2
    Last Post: 7th March 2008, 17:40
  4. Sending string from QT client to Java server
    By seanmu13 in forum Qt Programming
    Replies: 10
    Last Post: 3rd July 2007, 12:52
  5. Sending string from QT client to Java server
    By seanmu13 in forum Newbie
    Replies: 3
    Last Post: 3rd July 2007, 12:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.