Results 1 to 6 of 6
  1. #1
    PhQ's Avatar
    PhQ
    PhQ is offline Senior Member
    Join Date
    Mar 2010
    Location
    Lithuania
    Posts
    358
    Rep Power
    5

    Default Replacing text in JTextField

    Hey, how can I replace bad characters in JTextField ?
    For example if the user enters "%$&^&hello^%$%^ " it will the place it to "hello".
    Last edited by PhQ; 04-13-2010 at 11:28 PM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You can possibly use String#replaceAll(String regex, String replacement), but you have to have a very good idea of just what constitutes "bad characters".

  3. #3
    PhQ's Avatar
    PhQ
    PhQ is offline Senior Member
    Join Date
    Mar 2010
    Location
    Lithuania
    Posts
    358
    Rep Power
    5

    Default

    Is it possible to make it a char array for it or it has to be just a string?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by PhQ View Post
    Is it possible to make it a char array for it or it has to be just a string?
    You can certainly change a String to a char array by a simple method and can do this if you like, but I like the regex capabilities of String. Why do you want to do this? You may wish to go into greater detail about your problem.

  5. #5
    PhQ's Avatar
    PhQ
    PhQ is offline Senior Member
    Join Date
    Mar 2010
    Location
    Lithuania
    Posts
    358
    Rep Power
    5

    Default

    I'm making a registration form, and I've made an account with an username like this: 435345"), and when I've tried to login it just didn't log me in. Uhh its hard to explain...
    For example my username was : phq.
    I have made a new account : 23423")
    When I try to login on to phq it just doesn't do it.
    Basically I need it for security reasons.
    Last edited by PhQ; 04-14-2010 at 12:31 AM.

  6. #6
    PhQ's Avatar
    PhQ
    PhQ is offline Senior Member
    Join Date
    Mar 2010
    Location
    Lithuania
    Posts
    358
    Rep Power
    5

Similar Threads

  1. grabbing text from JTextField and replace it.
    By jimmy-lin in forum New To Java
    Replies: 1
    Last Post: 11-16-2009, 09:09 AM
  2. Replies: 8
    Last Post: 08-13-2009, 04:23 AM
  3. Replies: 1
    Last Post: 01-30-2009, 06:44 PM
  4. Replies: 0
    Last Post: 05-26-2008, 04:26 PM
  5. Replies: 5
    Last Post: 01-17-2008, 09:01 PM

Posting Permissions

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