I need a special behavior from eval, to evaluate strings like:
'5a + 6b + 3a + 11b'
into
'8a + 17b'
Is it possible? If it is, can you give a proper example? I found this example recently, where the talk was about evaluating strings with meters and inches.
...
Is there any method in .net that wraps phrases given a maximum length for each line?
Example:
Phrase: The quick red fox jumps over the lazy cat
Length: 20
Result:
The quick red fox
jumps over the lazy
cat
...
Here I am thinking I know how to use lists in Perl, when this happens. If I do this (debugging code, prettiness not included):
#! /usr/bin/perl -w
use strict;
my $temp1 = "FOOBAR";
my $temp2 = "BARFOO!";
my @list = { $temp1, $temp2 };
print $temp1; #this works fine
print $list[0]; #this prints out HASH(0x100a2d018)
It looks like I...
I am uploading a image file to the server.
Now after uploading the file to the server I need to rename the file with an id, but the extension of the file should be retained.
Eg: if I upload the file image1.png then my server script should retain the extension .png. But I need to change the substring to some other substring (primary key ...
I want to do following 2 things
1)i want retrive the list of all files in a directory
2)and then i want to remove their extensions
eg: if i get a list of fils as A.png ,B.png,C.jpeg,D.txt
I want to get A,B,C,D
How do i do that in php?
...
Hi, I have a string, with line breaks in my database.
I want to put that string in an array, and for every new line, jump one index place in the array.
If the string is:
"My text1(here is a line break)My text2(here is a line break)My text3"
The result I want is this:
array[0] = "My text1"
array[1] = "My text2"
array[2] = "My text...
Hey everyone,
I was wondering if there was a way to read all of the "words" from a line of text.
the line will look like this: R,4567890,Dwyer,Barb,CSCE 423,CSCE 486
Is there a way to use the comma as a delimiter to parse this line into an array or something?
...
Hello,
I am new to ruby and currently trying to operate on each character separately from a base String in ruby. I am using ruby 1.8.6 and would like to do something like:
"ABCDEFG".each_char do|i|
puts i
end
This produces a undefined method `each_char' error.
I was expecting to see a vertical output of:
A
B
C
D
..etc
Is the each...
Hi, I want to split a string in C#.NET that looks like this:
string Letters = "hello";
and put each letter (h, e, l, l, o) into an array or ArrayList. I have no idea what to use as the delimiter in String.Split(delimiter). I can do it if the original string has commas (or anything else):
string Letters = "H,e,l,l,o";
string[] AllLett...
I have a requirement to grep a string or pattern (say around 200 characters before and after the string or pattern) from an extremely long line ed file. The file contains streams of data (market trading data) coming from a remote server and getting appended onto this line of the file.
I know that I can match lines containing a specific...
I am reading a char array from a file in and then converting it too a string using the String constructor.
read = fromSystem.read(b);
String s = new String(b);
This code has been in the program for ages and works fine, although until now it has been reading the full size of the array, 255 chars, each time. Now I am reusing the class ...
I cant figure out preg_replace at all, it just looks chinese to me, anyway I just need to remove "&page-X" from a string if its there.
X being a number of course, if anyone has a link to a useful preg_replace tutorial for beginners that would also be handy!
...
Hi,
I could find the code to convert a hexadecimal string into a signed int (using strtol), but I can't find something for short int (2 bytes). Here' my piece of code :
while (!sCurrentFile.eof() )
{
getline (sCurrentFile,currentString);
sOutputFile<<strtol(currentString.c_str(),NULL,16)<<endl;
}
My idea is to read a file with 2 byt...
Hi all!
Well i got a socket that receives binary data and I got that data into an string, containing values and strings values too. (for example "0x04,h,o,m,e,....")
How can i search for an hex substring into that string?
I.e. i want to search "0x02,0x00,0x01,0x04".
I'm asking for a c++ version of python 'fooString.find("\x02\x00\x01...
Hi all,
I started on a little toy project in C lately and have been scratching my head over the best way to mimic the strip() functionality that is part of the python string objects.
Reading around for fscanf or sscanf says that the string is processed upto the first whitespace that is encountered.
fgets doesn't help either as I still...
Whats the most efficient way of removing a 'newline' from a std::string?
...
I have a string that contains a character � I haven't been able to replace it correctly.
String.replace("�", "");
doesn't work, does anyone know how to remove/replace the � in the string??
...
Hi,
Given a string s and an array of smaller strings, T, design a method to search s
for each small string in T.
Thanks.
...
I just discovered something. If I type this:
echo $var1 , " and " , $var2;
it is the same as:
echo $var1 . " and " . $var2;
What is the actual of concatenation operator in php? Using . or ,?
...
I need to return just the text contained within square brackets in a string. I have the following regex, but this also returns the square brackets:
var matched = mystring.match("\\[.*]");
A string will only ever contain one set of square brackets, e.g.:
Some text with [some important info]
I want matched to contain 'some important ...