• Post Reply Bookmark Topic Watch Topic
  • New Topic

tab  RSS feed

 
Kevin Tysen
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I am parsing a line of text and I want to look for some character like the letter b, I would use some command like this:

if (myString.charAt(ind) == 'b'){
doSomething();
}

So, if I am looking for a tab instead of a regular character, what command should I use?
 
Svend Rost
Ranch Hand
Posts: 904
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kevin,

I havn't tested the following.. but it should work

You need something like:

if (myChar == *tab*) do something


You need to find the value for *tab*. I'll give you two hints (both which
should work):

1. Ever heard of escape characters? such as "\n"

2. Each char you might type has an (ascii) value that the computer understands.


/Svend Rost

More hints in the following.. but give it a try yourself before you look...








ad 1: Try to print the following: "My name \n is Kevin. I \t like Java"
ad 2: Look at the Ascii Table and try to search for the horizontal tab (HT).
 
Nils Alexander
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use something like this:



If you don't now where the tab resides in you string use:

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!