split

How do I split a string at an arbitrary index?

How can I split up a string into pieces? For example, how can I place "orld." into a variable called one, "Hello" into a variable called three, and " w" into two? #include <string.h> #include <stdio.h> int main(void) { char *text ="Hello World."; /*12 C*/ char one[5]; char two[5]; char three[2]; return 1; } ...

Splitting gzipped logfiles without storing the ungzipped splits on disk.

I have a recurring task of splitting a set of large (about 1-2 GiB each) gzipped Apache logfiles into several parts (say chunks of 500K lines). The final files should be gzipped again to limit the disk usage. On Linux I would normally do: zcat biglogfile.gz | split -l500000 The resulting files files will be named xaa, xab, xac, etc ...

IE won't split string with Javascript

Hi, I have the following code: $('#smallcart .plusone').live('click',function(){ var id = $(this).attr('id'); articlenr = id.split('_')[1]; }); this works fine in FF, safari, Chrome, however in IE (7 and 8) it throws an error on the split-function (this property or method is not supported by this object). if I alert the 'id'-v...

Strange string split behaviour

I'm requesting data from my server and receive a string in the form of 2|bit.ly|1||1| and | should be the seperator. I though the following piece of code should do the work BufferedReader br = null; ... br = new BufferedReader(new InputStreamReader(inputStream)); ... String line; String[] columns; ContentValues values; while((line =...

How can I limit the number of returned items in Perl's split?

I got a problem when I parse a complex file which include thousands of lines. I already implemented my Perl script like this days ago. my ($head, $tail) = split /=/, $line; Nearly all my source file $line style as below: constant normalLines = <type value> /* hello world */ and I can get the output $tail = /* hello world ...

how to match only once in regex perl

$line = " TEST: asdas :asd asdasad s"; if ($line =~ /(.*):(.*)/ { print "$1 = $2 " } I was expecting TEST =asdas :asd asdasad s but its not working ? what is issue ...

Passing a boost::unordered_set as the result map to boost::split

Does anyone know if it's kosher to pass a boost::unordered_set as the first parameter to boost::split? Under libboost1.42-dev, this seems to cause problems. Here's a small example program that causes the problem, call it test-split.cc: #include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/split.hpp> #in...

How to Parse text data and store the same in array with splitting in j2me?

How to Parse text data and store the same in array with splitting in j2me? I have proceeded with the following code and i get to see all the text data but can't go any further. Can you guide me? /* * To change this template, choose Tools | Templates * and open the template in the editor. */ import java.io.*; import javax.microedition...

ruby regex split difficulties, close but not quite

I am having quite the difficulty using regex in ruby to split a string along several delimiters these delimiters are: , / & and each of these delimiters can have any amount of white space on either side of the delimiter but each item can contain a valid space. a great example that I've been testing against is the string 1, 2 /3 and...

Split a string with php

I have a string called $gallery, $gallery is a list of image URLS The image urls are seperated by a semi- colon ;. Example http://www.website.com/image1.jpg;http://www.website.com/image2.jpg;http://www.website.com/image3.jpg How can I split this up and place each url in an image tag, I suppose using preg_split? Thanks ...

ASP.Net String Split not working

Here's my code Dim RefsUpdate As String() = Session("Refs").Split("-"C) Dim PaymentsPassedUpdate As String() = Session("PaymentsPassed").Split("-"C) Dim x as Integer For x = 1 to RefsUpdate.Length - 1 Dim LogData2 As sterm.markdata = New sterm.markdata() Dim queryUpdatePaymentFlags as String = ("UPDATE OPENQUERY (db,'SELECT * FROM...

Js RegExp every other character

I have random strings that are similar to this: 2d4hk8x37m or whatever. I need to split it at every other character. To split it at every character its simply: '2d4hk8x37m'.split(''); But i need every other character so the array would be like this: ['2d', '4h', 'k8', 'x3', '7m'] Your help is appreciated. Thanks! ...

operating over strings, python

How to define a function that takes a string (sentence) and inserts an extra space after a period if the period is directly followed by a letter. sent = "This is a test.Start testing!" def normal(sent): list_of_words = sent.split() ... This should print out "This is a test. Start testing!" I suppose I should use split()...

What does the Perl split function return when there is no value between tokens?

I'm trying to split a string using the split function but there isn't always a value between tokens. Ex: ABC,123,,,,,,XYZ I don't want to skip the multiple tokens though. These values are in specific positions in the string. However, when I do a split, and then try to step through my resulting array, I get "Use of uninitialized value"...

How to split a string in Ruby?

I have special strings like name1="value1" name2='value2'. Values can contain whitespaces and are delimited by either single quotes or double quotes. Names never contain whitespaces. name/value pairs are separated by whitespaces. I want to parse them into a list of name-value pairs like this string.magic_split() => { "name1"=>"value1",...

C++: Elegant way to split string and stuff contents into std::vector

I would like to split a string along whitespaces, and I know that the tokens represent valid integers. I would like to transform the tokens into integers and populate a vector with them. I could use boost::split, make a vector of token strings, then use std::transform. What is your solution? Using boost is acceptable. ...

How do I run through an array where the first array member is a string that needs to be split.

I have an array {{".txt|.doc|.docx", "100000"}, {".xls|.xlsx|.xxx" , "10000"}, ".npp", "100000"} I am trying to find a way to run a foreach loop on each member of the array in a loop while also checking the first member as a string not an array. The code will search for all docs greater than 10000 bytes, as long as the docs are txt, do...