Results 1 to 4 of 4
  1. #1
    kilyx is offline Member
    Join Date
    Nov 2011
    Posts
    9
    Rep Power
    0

    Default checking for quotes in a string

    I have a file which lines are composed in this way

    Java Code:
    9 "Huberman, B"
    i need to recognize if there're " in the line i'm reading
    how can i check this?it should be something like
    Java Code:
    array[1].substring(0,1).matches(" " ")
    where 'array' is the array obtained with the split method split("\\s+")

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: checking for quotes in a string

    i need to recognize if there're " in the line i'm reading
    If you want to check whether a string contains " (or any other character) you can do so with any of the String indexOf() methods. If you specify " with either a string or a character literal you will have to quote it:

    Java Code:
    '\"'  // the character "
    "\"" // the string "
    String also has startsWith() and endsWith() if you are sure the quotes only appear at the ends.

  3. #3
    kilyx is offline Member
    Join Date
    Nov 2011
    Posts
    9
    Rep Power
    0

    Default Re: checking for quotes in a string

    Thanks a lot!

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

Similar Threads

  1. Checking The Contents of a String
    By jayragz in forum New To Java
    Replies: 7
    Last Post: 05-26-2011, 10:15 AM
  2. Checking If A String Contains Symbols
    By SwissR in forum New To Java
    Replies: 7
    Last Post: 07-27-2010, 09:07 AM
  3. checking for ints in a String
    By SteroidalPsycho in forum New To Java
    Replies: 1
    Last Post: 03-26-2010, 06:09 PM
  4. Help with checking for a certain format in a String
    By SteroidalPsycho in forum New To Java
    Replies: 2
    Last Post: 03-26-2010, 04:56 AM
  5. String, quotes and args
    By mac in forum New To Java
    Replies: 8
    Last Post: 02-04-2010, 04:24 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
  •