Background
Python has "textwrap" and "dedent" functions. They do pretty much what you expect to any string you supply.
textwrap.wrap(text[, width[, ...]])
Wraps the single paragraph in text (a string) so every line is at most width characters long. Returns a list of output lines, without final newlines.
textwrap.dedent(tex...
Hi folks,
I have a string that will be different each time but follow the form of
-3.33,-46.53,37.39,26.55,97.11,68.46,-32.46,-5.89,-62.89,-7.9,
and i want to remove each number and store as an double in an array.
even pseudocode would be great i'm drawing a blank.
Cheers
...
Hi folks,
I'm reading a file into an array and trying to take out the numbers and put them as a double in an array of their own. And apparently my middle name must be "Error". From what I can tell the code is ok....at least theres nothing jumping out at me. Here it is in all it's glory.
import java.io.BufferedInputStream;
import java.io...
Hey guys,
I am looping through a large text file and im looking for lines that contain no more than 3 different characters (those characters, however, can be repeated indefinitely). I am assuming the best way to do this would be some sort of regular expression.
All help is appreciated.
(I am writing the script in PHP, if that helps)
...
Trying to display current time with PHP (using this):
$date = date('m/d/Y h:i:s a', time());
echo $date;
As simple as it gets. How do I localize it? I want to translate the months and days to Hebrew.
Thanks.
...
Hi guys ,
in the following code
This is what i do ,
private Speed string[] { get; set;}
internal speed duration.slow
public setspeed { get { return speed } set { speed = value;
string temp = "{ duration :"+speed.tostring()+"}";
this.Speed = new string[] {temp};
} }
the properties are all appended to the script in terms of "atribut...
I'm trying to find a relatively easy and reliable method to extract the base URL from a string variable using JavaScript/jQuery.
For example, given something like:
http://www.sitename.com/article/2009/09/14/this-is-an-article/
I'd like to get:
http://www.sitename.com/
Is a regular expression the best bet? If so, what statement could...
Can I assign each value in an array to separate variables in one line in C#? Here's an example in Ruby code of what I want:
irb(main):001:0> str1, str2 = ["hey", "now"]
=> ["hey", "now"]
irb(main):002:0> str1
=> "hey"
irb(main):003:0> str2
=> "now"
I'm not sure if what I'm wanting is possible in C#.
Edit: for those suggesting I jus...
So here's the deal: I'm trying to open a file (from bytes), convert it to a string so I can mess with some metadata in the header, convert it back to bytes, and save it. The problem I'm running into right now is with this code. When I compare the string that's been converted back and forth (but not otherwise modified) to the original byt...
String contains a bunch of useful methods such as String.replace(CharSequence, CharSequence) that are completely missing from StringBuilder. Is there a reason why?
Is there an easy way to implement these methods without the huge overhead of invoking StringBuilder.toString() which copies the string every time?
...
Hello!
In my user database table, I take the MD5 hash of the email address of a user as the id.
Example: email([email protected]) = id(d41d8cd98f00b204e9800998ecf8427e)
Unfortunately, I have to represent the ids as integer values now - in order to be able to use an API where the id can only be an integer.
Now I'm looking for a way ...
I need to generate a string with n characters in Python. Is there a one line answer to achieve this with the existing Python library? For instance, I need a string of 10 letters:
string_val = 'abcdefghij'
...
I have a list of 400 strings that all end in "_GONOGO" or "_ALLOC". When the application starts up, I need to strip off the "_GONOGO" or "_ALLOC" from every one of these strings.
I tried this:
'string blah = Regex.Replace(string, "(_GONOGO|_ALLOC)", ""));'
but it is MUCH slower than a simple conditional statement like this:
if (strin...
Suppose I have a string called "[email protected]". I want to store the string before and after "@" into 2 separate strings. What would be the easiest method of finding the "@" character or other characters in the string?
...
Hi,
it's really annoying how C# seems to force you to explicitly name the index of every parameter in String.Format, if you want to add another parameter somewhere you either have to reindex the string or put your new parameter at the end. Is there a way to get C# to do this automatically?
eg (I know this is pointless pedants, it's jus...
We are having trouble getting a Unicode string to convert to a UTF-8 string to send over the wire:
// Start with our unicode string.
string unicode = "Convert: \u10A0";
// Get an array of bytes representing the unicode string, two for each character.
byte[] source = Encoding.Unicode.GetBytes(unicode);
// Convert the Unicode bytes to U...
The title of this is kind of awkward; I wasn't really sure how to sum this up. I know how I can do this, I'm just not sure how to do it efficiently. Here's my problem:
I have a string as input. Let's say:
foo bar
And I have a very large set of strings (tens of thousands). Let's say:
foo, baz, bar, blah, foo bar, foo baz
I...
I've read some posts with some self implementations of this but I think now there should be some method in the ASP.NET MVC that should have this functionality.
I suppose there is some kind of method that can do what string.Format does:
string.Format("example {0}", 1);
but instead of using {0} can work with variables names just like...
Does anyone know of an R package that solves the longest common substring problem? I am looking for something fast that could work on vectors.
...
I can easily concatenate two variables, foo and bar, as follows in Tcl: "${foo}${bar}".
However, if I don't want to put an intermediate result into a variable, how can I easily concatenate the results of calling some proc?
Long hand this would be written:
set foo [myFoo $arg]
set bar [myBar $arg]
set result "${foo}${bar}"
Is there s...