split

How can Perl split a line on whitespace except when the whitespace is in doublequotes?

I have the following string: StartProgram 1 ""C:\Program Files\ABC\ABC XYZ"" CleanProgramTimeout 1 30 I need a regular expression to split this line but ignore spaces in double quotes in Perl. The following is what I tried but it does not work. (".*?"|\S+) ...

Split a string in ASP Javascript

I am trying to split a string from a recordset that is in the format DD/MM/YYYY. So basically something like: Homework.Fields.Item("DateDue").Value.split("/") But that doesn't work, Normally I can do: String(Homework.Fields.Item("DateDue").Value).split("/") But using String() turns the value into a long thing like: Wed Oct 26 00:...

How to split a string in PHP [solved]

Hello, I have a long string resulted from encoding a binary file -an image file- (in base 64). Is there a particulary method (or rule) I should follow when spliting it? Edit: I want to write the string to a xml file, but in order to do this I must split it in smaller chunks. Edit2: I would like to split it by length (I think that is more...

how to split multiple strings

Hi guys, im currently having troubles on my codes in C#. I want to split strings with no fix values. here' my code please help me fix this. protected void GridViewArchives_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView drView = (DataRowView)e.Row.DataI...

PHP - Split a string

Hi all, Another n00b question. $ab = "A00000001" echo $a; // gives result "A" echo $b; // gives result "1" $ab = "B01250" echo $a; // gives result "B" echo $b; // gives result "1250" What's the easiet single way to convert "ab" to "a" and "b" in both examples above? Thanks! ...

Split text into words problem PHP, complicated problem

Hi, I am trying to split the text into words: $delimiterList = array(" ", ".", "-", ",", ";", "_", ":", "!", "?", "/", "(", ")", "[", "]", "{", "}", "<", ">", "\r", "\n", '"'); $words = mb_split($delimiterList, $string); which works quite fine with strings but I am stuck in some cases where I have to do with numb...

Is there a way to split a string by every nth seperator in Python?

For example, if I had the following string: "this-is-a-string" Could I split it by every 2nd "-" rather than every "-" so that it returns two values ("this-is" and "a-string") rather than returning four? ...

Selectively counting delimited field values and creating a hash using map

I have a pipe delimited text file containing, among other things, a date and a number indicating the lines sequence elsewhere in the program. What I'm hoping to do is from that file create a hash using the year as the key and the value being the maximum sequence for that year (I essentially need to implement an auto-incremented key per y...

Split string in 512 char chunks [C#]

Hello. Maybe a basic question but lets say I have a string that is 2000 characters long, I need to split this string into max 512 character chunks each. Is there a nice way, eg. a loop for doing this? Thank you :-) ...

jQuery split long ul list in smaller lists

I have a long UL list I need to break up in smaller lists containing about 20 items each. I was thinking I could use something like $(function() { $("ul li:nth-child(20n)").after("</ul><ul>"); }); but that's not the case. Any idea how to use jQuery in a way that uses minimal CPU? Thanks ...

How to split a string by commas positioned outside of parenthesis?

Hi, I got a string of such format: "Wilbur Smith (Billy, son of John), Eddie Murphy (John), Elvis Presley, Jane Doe (Jane Doe)" so basicly it's list of actor's names (optionally followed by their role in parenthesis). The role itself can contain comma (actor's name can not, I strongly hope so). My goal is to split this string into ...

Why does this split() fail?

I'm trying to get the extension of a filename, but for some reason I can't make split work: System.out.println(file.getName()); //gNVkN.png System.out.println(file.getName().split(".").length); //0 What am I doing wrong? ...

How to count occurence of partly-matching words with VB.NET?

I am using VB 9.0 to split a text file and then count occurrences of the term <sequence>. Supposing I want also to count occurrences of the same term in a different format, e.g. <sequence and then group them together such that I output the result to a text box, i.e. txtMyTerms.Text=<sequence>+<sequence. How to do it? My current code is...

split a string vector [R]

I have the following vector: tmp3 <- c("1500 2", "1500 1", "1510 2", "1510 1", "1520 2", "1520 1", "1530 2", "1530 1", "1540 2", "1540 1") I would like to just retain the second number in each of the atoms of this vector so it would read: c(2, 1,2,1,2,1,2,1,2,1). ...

Splitting up html code tags and content

Does anyone with more knowledge than me about regular expressions know how to split up html code so that all tags and all words are seperated ie. <p>Some content <a href="www.test.com">A link</a></p> Is seperated like this: array = { [0]=>"<p>", [1]=>"Some", [2]=>"content", [3]=>"<a href='www.test.com'>,...

Java RegEx - Regular expression to split a paragraph with start and end ....

Hi All, I am new to java regex.Please help me. Consider the below paragraph, Paragraph : Name abc sadghsagh hsajdjah Name ggggggggg !!! Name ggg dfdfddfdf Name !!! Name hhhh sahdgashdg Name asjdhjasdh ...

How to split a string in a Windows batch file?

Suppose I have a string "AAA BBB CCC DDD EEE FFF". How can I split the string and retrieve the nth substring, in a batch file? The equivalent in C# would be "AAA BBB CCC DDD EEE FFF".Split()[n] EDIT Thanks for the helpful answers. In the end I decided that this was trying to make a batchfile perform unnatural acts, so I went with...

cut out part of a string

Say, I have a string "hello is it me you're looking for" I want to cut part of this string out and return the new string, something like s = string.cut(0,3); s would now be equal to: "lo is it me you're looking for" EDIT: It may not be from 0 to 3. It could be from 5 to 7. s = string.cut(5,7); would return "hellos it me you'...

how to split a string to what I want in python

I have string ling like this: 'Toy Stroy..(II) (1995)' I want to split the line to two parts like this: ['Toy Story..(II)','1995'] How can I do it? thanks ...

In Perl, how can I get the fields in this CSV string into an array without spaces?

Hi, if I have a string, say: my $string = "A, B,C, D , E "; How can I put this into an array in Perl without the leading and trailing spaces? So what I want is only a single letter in each array element. What I currently do is this: my @groups = split /,\s*/, $string; But this is obviously not enough, as the trailing spaces are st...