split

Split a number by decimal point in php

How do I split a number by the decimal point in php? I've got $num = 15/4; which turns $num into 3.75. I would like to split out the 3 and the 75 parts, so $int = 3 and $dec = 75. My non-working code is: $num = 15/4; // or $num = 3.75; list($int, $dec) = split('.', $num); but that results in empty $int and $dec. Thanks in advance. ...

How to split strings into text and number?

I'd like to split strings like these 'foofo21' 'bar432' 'foobar12345' into ['foofo', '21'] ['bar', '432'] ['foobar', '12345'] Does somebody know an easy and simple way to do this in python? ...

How do I split email address/password string in two in Python?

Lets say we have this string: [18] [email protected]:pwd: [email protected] is the email and pwd is the password. Also, lets say we have this variable with a value f = "[18] [email protected]:pwd:" I would like to know if there is a way to make two other variables named var1 and var2, where the var1 variable will take the exact email info...

Python Split String

Lets Say we have Zaptoit:685158:[email protected] How do you split so it only be left 685158:[email protected] ...

Split Java String by New Line

I'm trying to split text in a JTextArea using a regex to split the String by \n However, this does not work and I also tried by \r\n|\r|n and many other combination of regexes. Code: public void insertUpdate(DocumentEvent e) { String split[], docStr = null; Document textAreaDoc = (Document)e.getDocument(); try { doc...

C#, a String's Split() method

C#, a String's Split() method, how can I put the resulting string[] into an ArrayList or Stack? ...

Close a split window in Vim without resizing other windows

If I have a Vim window open with 2 splits in it (3 total buffers visible) and I've adjusted the viewport of each split, then I close one buffer, the other two buffer's viewport's are automatically resized. Is there a way to maintain or at least better scale the split when I close a buffer? 1) Vim window with three splits, custom size: ...

Python Split?

I have this list ["[email protected] : martin00", ""], How do i split so it only be left [email protected]:martin00 ...

How to split a string while preserving line endings?

I have a block of text and I want to get its lines without losing the \r and \n at the end. Right now, I have the following (suboptimal code): string[] lines = tbIn.Text.Split('\n') .Select(t => t.Replace("\r", "\r\n")).ToArray(); So I'm wondering - is there a better way to do it? Accepted answer string[] lines ...

How to split using a prefix character using regular expressions?

I would like to split the example string -- ~Peter~Lois~Chris~Meg~Stewie on the character '~' and have the result be Peter Lois Chris Meg Stewie Using a standard string split function in javascript or C# the first result is of course an empty string. I'd like to avoid having to ignore the first result because the first result may act...

Split Java String in chunks of 1024 bytes

What's an efficient way of splitting a String into chunks of 1024 bytes in java? If there is more than one chunk then the header(fixed size string) needs to be repeated in all subsequent chunks. ...

Java split() method strips empty strings at the end?

Check out the below program. public class test { /** * @param args */ public static void main(String[] args) { try { String data = null; // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new FileReader(new File("D:/sample.txt"))); while((data=br.readLine())!= null){ ...

Split tags in python

I have a file that contains this: <html> <head> <title> Hello! - {{ today }}</title> </head> <body> {{ runner_up }} avasd {{ blabla }} sdvas {{ oooo }} </body> </html> what is the best more pythonic way to extract the {{today}}, {{runner_up}} etc? I know it can be done with splits/r...

How must I declare the regex for Perl's split?

I came across this Perl construct today: @foo = split("\n", $bar); That works well for splitting a large string into an array of lines for UNIX-type line endings, but leaves a trailing \r for Windows. So I changed it to: @foo = split("\r?\n", $bar); Which splits the string by lines and doesn't leave a trailing \r (tested under Acti...

Losing newlines in div content in IE 7

I'm trying to split the innerText of a div on the newlines in the source for it. This works fine with: $('div').text().split("\r\n|\r|\n") But this fails in IE 7, due to the newlines apparently being stripped out. jQuery 1.3.2 doesn't appear to be at fault since i also tried both: $('div')[0].innerText.split("\r\n|\r|\n") and $('d...

C# Extension Method - String Split that also accepts an Escape Character

I'd like to write an extension method for the .NET String class. I'd like it to be a special varation on the Split method - one that takes an escape character to prevent splitting the string when a escape character is used before the separator. What's the best way to write this? I'm curious about the best non-regex way to approach it....

Trying to use String.split() regex on String created with Formatter

Hi All I am a newcomer here, I am using the following code from an open source library (Matrix Toolkits for Java) which outputs the following matrix 1000 1000 5 3 5 1.000000000000e+00 I am trying to do a String split that will return me 1000,1000,5 I tried using String[] parts = str.trim()...

splitting html table in asp.net

I have a html file which has a huge table with 4 columns and multiple rows. I want to display it in an asp 2.0/3.5 page, such that it's first 2 columns appear in one area and other two appear in another area adjacent to it. Some thing like splitting the table in two and displaying. Is there any way i can achieve it? ...

python, regex split and special character

How can I split correctly a string containing a sentence with special chars using whitespaces as separator ? Using regex split method I cannot obtain the desired result. Example code: # -*- coding: utf-8 -*- import re s="La felicità è tutto" # "The happiness is everything" in italian l=re.compile("(\W)").split(s) print " s> "+s prin...

How do I split a string with multiple separators in javascript?

How do I split a string with multiple separators in JavaScript? I'm trying to split on both commas and spaces but, AFAIK, js's split function only supports one separator. ...