Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separate string by tab characters

I have a text file that is tab-delimited. How can I separate this string into substrings for an array by detecting the tabs?

like image 736
Jimmy Avatar asked May 09 '10 12:05

Jimmy


People also ask

How do you split a string by tab?

Just use the String. Split method and split on tabs (so probably first one split on newlines to get the lines and then one on tabs to get the values).

How do you split a string by tab in Python?

split() method to split a string by tabs, e.g. my_list = my_str. split('\t') . The str. split method will split the string on each occurrence of a tab and will return a list containing the results.

How do you separate a string by a specific character?

To split a string with specific character as delimiter in Java, call split() method on the string object, and pass the specific character as argument to the split() method. The method returns a String Array with the splits as elements in the array.

How do you split a string by tab in Uipath?

reqStr = Str.split(" ".ToCharArray)(2) Thanks for your quick response. Its not a space in each value, but its a tab space in each value. Can you please enter the tab space in each value and find out the value of 123. Screenshot for your reference.


2 Answers

string s = "123\t456\t789"; string[] split = s.Split('\t'); 
like image 157
CD.. Avatar answered Sep 20 '22 04:09

CD..


If you use String.split() you can split the String around any regular expression, including tabs. The regex that matches tabs is \t, so you could use the following example;

String foo = "Hello\tWorld"; String[] bar = foo.split("\t"); 

Which would return a String array containing the words Hello and World

like image 28
Jivings Avatar answered Sep 20 '22 04:09

Jivings