split

get the last element of a splitted string array in javascript

I need to get the last element of the splitted array with multiple seperators. if there's no array it should return the string the seperators are "commas" and "space" if the string is "how,are you doing, today?" it should return "today?" if the input were "hello" the output should be "hello" how can i do this in javascript DUPE: htt...

Effective way to iteratively append to a string in Python?

I'm writing a Python function to split text into words, ignoring specified punctuation. Here is some working code. I'm not convinced that constructing strings out of lists (buf = [] in the code) is efficient though. Does anyone have a suggestion for a better way to do this? def getwords(text, splitchars=' \t|!?.;:"'): """ Genera...

How do you tokenise / tokenize / split a delimited string in Perl?

How do you split a string e.g. "a:b:c:d" into tokens for parsing in Perl? (e.g. using split?) Looking for clear, straightforward answer above all (but do add any interesting tidbits of info afterwards). ...

Perl regex split with new lines

I'm new to Perl and am working on a project for school and am stuck. Input: A given text file containing email addresses delimited by a space, tab, ",", ";" or “:” [can be on separate lines]. I am trying to read in the email addresses and put them into an array. I am able to parse the data on one line however if there are line breaks ...

Does VBscript have modules? I need to handle CSV

I have a need to read a CSV file, and the only language I can use is VBscript. I'm currently just opening the file and splitting on commas, and it's working OK because there aren't any quoted commas in fields. But I'm aware this is an incredibly fragile solution. So, is there such a thing as a VBscript module I can use? Somewhere to ge...

split string based on regexp

Hi, I want to split a string in C# that looks like a : b : "c:d" so that the resultant array will have Array[0] = "a" Array[1] = "b" Array[2] = "c:d" what regexp do I use to achieve the required result. Many Thanks ...

Best way to chop a signature off an email body

Hello, I am parsing out some emails. Mobile Mail, iPhone and I assume iPod touch append a signature as a separate boundary, making it simple to remove. Not all mail clients do, and just use '--' as a signature delimiter. I need to chop off the '--' from a string, but only the last occurrence of it. Sample copy hello, this is some e...

Java's Scanner vs String.split() vs StringTokenizer; which should I use?

I am currently using split() to scan through a file where each line has number of strings delimited by '~'. I read somewhere that Scanner could do a better job with a long file, performance-wise, so I thought about checking it out. My question is: Would I have to create two instances of Scanner? That is, one to read a line and another ...

C# Regex Split - everything inside square brackets

I'm currently trying to split a string in C# (latest .NET and Visual Studio 2008), in order to retrieve everything that's inside square brackets and discard the remaining text. E.g.: "H1-receptor antagonist [HSA:3269] [PATH:hsa04080(3269)]" In this case, I'm interested in getting "HSA:3269" and "PATH:hsa04080(3269)" into an array of st...

Split string into a list in Python

I want my python function to split a sentence (input) and store each word in a list. The code that I've written so far splits the sentence, but does not store the words as a list. How do I do that? def split_line(text): # split the text words = text.split() # for each word in the line: for word in words: # pri...

Split array into smaller arrays.

I am looking for a way to easily split a python array in half. So that if I have an array: A = [0,1,2,3,4,5] I would be able to get: B = [0,1,2] C = [3,4,5] ...

Implementing and applying a string split in T-SQL

I have this statement in T-SQL. SELECT Bay From TABLE where uid in ( select B_Numbers from Info_Step WHERE uid = 'number' ) I am selecting "multiple" BAYs from TABLE where their uid is equal to a string of numbers like this: B_Numbers = 1:45:34:98 Therefore, I should be selecting 4 different BAYs from TABLE. I basically need t...

How can split a string which contains only delimiter?

Hi All : I am using the following code: String sample = "::"; String[] splitTime = sample.split(":"); // extra detail omitted System.out.println("Value 1 :"+splitTime[0]); System.out.println("Value 2 :"+splitTime[1]); System.out.println("Value 3 :"+splitTime[2]); I am getting ArrayIndexOutofBound exception. How does String.split()...

Split a text into single words

Hello! I would like to split a text into single words using PHP. Do you have any idea how to achieve this? My approach: function tokenizer($text) { $text = trim(strtolower($text)); $punctuation = '/[^a-z0-9äöüß-]/'; $result = preg_split($punctuation, $text, -1, PREG_SPLIT_NO_EMPTY); for ($i = 0; $i < count($result); $i...

A method to reverse effect of java String.split()?

I am looking for a method to combine an array of strings into a delimited String. An opposite to split(). I've seen this in other languages. Wanted to ask the forum before I try writing my own( since the JDK has everything...) Thanks, ...

.NET System.OutOfMemoryException on String.Split() of 120 MB CSV file

I am using C# to read a ~120 MB plain-text CSV file. Initially I did the parsing by reading it line-by-line, but recently determined that reading the entire file contents into memory first was multiple times faster. The parsing is already quite slow because the CSV has commas embedded inside quotes, which means I have to use a regex spli...

Javascript won't split using regex

Since I started writing this question, I think I figured out the answers to every question I had, but I thought I'd post anyway, as it might be useful to others and more clarification might be helpful. I was trying to use a regular expression with lookahead with the javascript function split. For some reason it was not splitting the st...

Separating SQL Results Into Ranges

I would like to take a simple query on a list of members that are indexed by a number and group them into 'buckets' of equal size. So the base query is: select my_members.member_index from my_members where my_members.active=1; Say I get 1000 member index numbers back, now I want to split them into 10 equally sized groups by a max and...

ActionScript2: Split a text with two delimiter, Help

I try to create a project with use a Split in AC2. this I have in_pers = 3x5+5x3+6x8; var tmp:Array = in_pers.split("+"); trace(tmp); //output == 3x5, 5x3, 6x8 but, how if in_pers = 3x5+5x3-6x8-4x2; how can I get the result 3x5, 5x3, 6x8, 4x2 how to use the split with two delimiter. Best regard.. ...

How to split single quoted comma delimited values containing commas in Ruby

Say I have a string with comma delimited values enclosed in single quotes that may or may not include commas, like this: "'apples,bananas','lemons'" and I want to split that into an array ["apples,bananas", "lemons"] Apparently, if I split(',') the string I get [ "'apples", "bananas'", "lemons" ] which I don't understand. The o...