Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Split Method with single quotes

Tags:

c#

parsing

I have a text file with lines of something like this:

(LIST (LIST 'Abbott 'Ashley 'J ) '8697387888 '[email protected] 2.3073320999676614 )

I have read the file into individual string array elements, but I want to split into individual array elements so it is more useful like:

|Abbott|Ashley|J|8697387888|[email protected]|2.3073320999676614|

However, I can't figure out how to do this. Here is what I have tried, but doesn't work due to syntax.

for (int Count = 0; Count < lines.Length; Count++)
{
    Split = lines[Count].Split(''');
}

I'm trying to use the single quotes as the split break.

like image 345
shadowjfaith Avatar asked Oct 23 '12 18:10

shadowjfaith


People also ask

How to split string with double quotes in java?

Use method String. split() It returns an array of String, splitted by the character you specified.

What is the limit of the string split method?

This variant of the split method takes a regular expression as a parameter and breaks the given string around matches of this regular expression regex. Here, by default limit is 0. Returns: An array of strings is computed by splitting the given string.

What is the use of split method in JavaScript?

This variant of the split method takes a regular expression as a parameter and breaks the given string around matches of this regular expression regex. Here, by default limit is 0. Returns: An array of strings is computed by splitting the given string. Throws: PatternSyntaxException – if the provided regular expression’s syntax is invalid.

What are the two variants of split method in Java?

Following are the two variants of split() method in Java: Parameters: regex - a delimiting regular expression Limit - the result threshold Returns: An array of strings computed by splitting the given string. Throws: PatternSyntaxException - if the provided regular expression’s syntax is invalid.

What is the difference between single quotes and double quotes?

The choice between both the types (single quotes and double quotes) depends on the programmer’s choice. Generally, double quotes are used for string representation and single quotes are used for regular expressions, dict keys or SQL.


1 Answers

Try using a \.

 Split = lines[Count].Split('\'');
like image 168
Daniel A. White Avatar answered Sep 28 '22 20:09

Daniel A. White