I have a variable that reads as _123456 and I need to delete the underscore prefix on this variable before storing it to a field. How do I do this?
var value = "_123456"
Hey.
My code crashes at this function (at the stringByAppendingFormat: with error objc_msgSend() selector name: stringByAppendingFormat).
This is that line:
// imagesPath = ...iPhone Simulator/4.0/Applications/NUMBERS/Documents/images
UIImage *image = [[UIImage alloc] initWithContentsOfFile:[imagesPath stringByAppendingFormat:@"/%d.png", [[self.postsArrayID objectAtIndex:row] intValue]]];
Could it have something to do with the retaining of objects?
Thanks :)
I am trying to format currency that will always contain 2 decimal digits, but if there are extra digits of accuracy to display up to five. As an example:
for value = 5.0
display: $5.00
for value = 5.023
display: $5.023
for value = 5.333333333333333
display: $5.33333
I have been playing with the .ToString() formatting, but I can't seem to find the right match of options.
Clarification:
I want to show from 2-5 decimals, truncating zeros after the second digit.
for value = 5.000000000000000
display: $5.00
for value = 5.333333333333333
display: $5.33333
I have the following code:
LPCTSTR strPermission = Method();
if (strPermission == L"0")
{
return true;
}
else
{
return false;
}
While debugging I can see that strPermission does equal "0", yet when I compare it like in the if statement it always returns false.
The only thing I can think of is that it is comparing the memory address of the variable rather than the variable value.
How do I compare strPermission to L"0" so that it would return true if strPermission equals "0".
Thank you!
I'm using the Twitter API streaming to collect thousand of tweets every minute.
They need to be matched to a list of keywords (can contain spaces).
This is my current method:
$text = preg_replace( '/[^a-z0-9]+/i', ' ', strtolower( $data['text'] ) );
$breakout = explode( " ", $text );
$result = array_intersect( $this->_currentTracks, $breakout );
I chop the tweet into words, and the matches them against my current keywords.
This works well for all the keywords without a space ofc.
If I wanted to find for example "Den Haag", It won't show up, because the string is exploded into words (based on the spaces).
Any ideas about how I can do this in a quick way?
Kind regards,
Tim
i have a username= LICTowner.
i need to get the prefix from the word LICTowner i.e LICT.
how to split the word and get the 4 letter prefix.
in asp.net using C#
I open a website with urlopen. I then put the website sourcecode into a variable like so
source = website.read()
When I just print the source it comes out formatted correctly, however when I try to iterate through each line each character is it's own line.
for example
when I just print it looks like this
<HTML> title</html>
When I do this
for line in source:
print line
it looks like this
<
H
T
M
L
... etc
I need to find a string that starts with "var" and then print that entire line.
Hi all, I have been trying to create an iphone app sending telnet command. However what puzzling me is that the sizes of certain strings are so much different, particularly when they include \n or \r. I listed out a few examples. Please assist.
const char *a = "play 25\n";
int sizeBitA1 = sizeof(a); // 8 units
int sizeBitA2 = sizeof("play 25\n"); // 9 units
const char *b = "\r\n";
int sizeBitB1 = sizeof(b); // 8 units
int sizeBitB2 = sizeof("\r\n"); // 3 units
I am currently working on an android project and I want to be able to startActivityForResult so that I can return an array of.
The array is an ArrayList<Spanned> lets say its called myArray.
From what I've read I can't return an array directly from the activty using the set result so I was thinking that once the array has added all the data to the array, I can then call the toString function on it, i.e. myArray.toString().
If I do this, I have no idea how I can then convert this back into the original ArrayList<Spanned>.
Thanks for any help you can provide.
I need to output a cell to an excel file. Before this I need to convert a date column of integers to datestrings. I know how to do this, but I am not able to put this new string array back into the cell -
mycell = { 'AIR' [780] [1] [734472] [0.01] ; ...
'ABC' [780] [1] [734472] [0.02]}
I did this --
dates = datestr(cell2mat(mycell(:,4))) ;
What I need as an answer is:
{'AIR' [780] [1] '14-Dec-2010' [0.01] ;
'ABC' [780] [1] '23-Dec-2010' [0.03] ; }
so that I can now send it to an excel file using xlswrite.m
Righto, firstly magic quotes & runtime are disabled correctly in php.ini, and confirmed by phpinfo().
PHP version: 5.3.4
MySQL version: 5.1.52
I'm only use mysql_real_escape_string on the data, after htmlspecialchars and a trim, that's all the data cleaning on the variable.
Yet, when I submit a single quote, the slash remains in the database.
When running mysql_query I'm using "' . $var . '", although in the past this hasn't changed anything (could be due to the double quotes?).
Any ideas? and please don't tell me about PDO/prepared statements, I'm aware of them and I have my reasons for doing it this way.
Thanks!
I am trying to write a recursive method to print n number of asteriks in a line and create a new line at the end.
So, TriangleOps.line(5);
would print
*****
This is the code I wrote:
public static void line (int n){
if(n>0){
System.out.println("*");
line(n-1);
}}
instead it prints
*
*
*
*
*
with a lot of space at the end. Can anyone tell me how to remove the line breaks?
I am aware there is a function strcasecmp() that compares cstrings ignoring case, but I was wondering if there is a function that does the same thing except with strings? I am working with a bunch of strings, and feel like it would be terribly inefficient to have to use c_str() each time I want to compare them with strcasecmp(). Should I just use cstrings instead of strings...?
Hi!
I'm writing a small C application that launchs a Matlab script (.m file).
I need to exchange some variables and I don't know how to get an array of chars that exists in Matlab.
I'm doing something like this:
enter code here
result = engGetVariable(ep,"X");
if (!result)
{
printf ("Error...");
exit -1;
}
int n = mxGetN(result);
char *varx = NULL;
memcpy(varx, mxGetData(result),n*sizeof(char));
It doesn't work. Does someone know how to get a Matlab string in C?
I've read Matlab documentation about engGetVariable() and the provided example but any of this things clarify me.
Hello,
typedef enum testCaseId
{
"TC-HIW-0019" = 0,
"TC-HIW-0020",
"TC-HIW-0021"
} testCaseId;
I need my test cases to be represented in enum. In my test function, I need to switch between the test cases like:
void testfunc(uint8_t no)
{
switch(no)
{
case 0:
case 1:
default:
}
}
So can anyone help on how to use enum to declare strings.
Hi,
I have a mySql database i want to display only 10 words from its body field which contain html codes, How i can do that, is there any php function to do that.
I have inherited the following line of code:
TCHAR temp[300];
GetModuleFileName(NULL, temp, 300);
However, this fails as the first 3 bytes are filled with garbage values (always the same ones though, -128, -13, 23, in that order). I said, well fine and changed it to:
TCHAR temp[300];
ZeroMemory(temp, 300);
GetModuleFileName(NULL, temp, 300);
but the garbage values persisted! Can someone explain what is going on and how to fix it?
Currently I'm trying to read through some basic cells, in this format:
+-------+-------+
| | |
+-------+-------+
Now I need to get the string representation of the cell's contents and send it off to another method. The problem is that the cells have no pre-defined length. I'm reading these from a file, so my easiest option should be to just use the Scanner I already have set up. Problem is, I don't really know how for this case.
I have a strong feeling that I need to use the pattern somehow, but I'm at a complete loss on how to do it.
I could also probably just build it up somehow, but that strikes me as being painfully slow.
I have texts in UTF-8 with diacritic characters also, and would like to check if first letter of this text is upper case or lower case. How to do this?
Hello
i have a question.
in short: i need a function which receives [NSDate date] and string @"2010-11-12" and returns the amount of days between those two dates.
more explanation:
I need to store a date from a server in the format @"2010-11-12" in my NSUserdefaults. The meaning of this date is the expireDate of a feature in an iPhone App. Everytime i press on a button for this feature i need to check if the difference in days between the current time-[NSDate date] and @"2010-11-12" is greater than 0. That means tahat the feature is disabled.
its making me crazy mabey its to dead simple.
Scala Newbie alert:
basically I'm trying to do something like this: where I pattern match and return a String.
scala> def processList(list: List[String], m: String): String={list foreach (x=> m match{
| case "test" => "we got test"
| case "test1"=> "we got test1"})}
:10: error: type mismatch;
found : Unit
required: String
def processList(list: List[String], m: String): String={list foreach (x= m match{
I know I can set a var and return it after the for comp... but that doesn't seem to be the Scala way.
given this code
namespace GridTests
{
public class Grid<T>
{
IEnumerable<T> DataSource { get; set; }
IList<Column> Columns = new List<Column>();
class Column
{
public string DisplayText { get; set; }
Func<T, object> Rowdata { get; set; }
}
}
}
I need to be able to loop through the columns collection and get the Rowdata's object value using the DisplayText.
Thanks
Is there a way to remove the period and everything after it using jQuery? The numbers following the period vary in length, so it's not as simple as finding the length.
For example:
<span class="changethis">505.234</span> <span class="changethis">23.93</span>
Thanks for your help!
P.S. (bonus) If there is a way to round up if it's x.5 or higher that would be awesome. Not essential though.
I found this code that replaces a string in a text file. But, I am trying to make it so that it replaces several strings in a text file.
My.Computer.FileSystem.WriteAllText("C:\windows\PrinterList2.txt", My.Computer.FileSystem.ReadAllText("C:\windows\PrinterList.txt").Replace("IT", "ADM-IT"), False)
For example, I need it to replace "IT" with "ADM-IT" and "AR" with "ADM-AR" and possibly a hundred or so more.
How can I get it to loop to do them all? Running this line of code over and over just overwrites the file with the last item for replacement.
Thanks in advance.
I use the ajax which sends back a string..
I want to convert the responsetext into a json object to process.
I tried eval and also , but doesn't works...
Wht to do?
My code is
function handleResponse() {
if(httpa.readyState == 4){
var response = httpa.responseText;
if(response!='empty')
{
alert(response);
var foo = eval('(' +strJSON+ ')');
alert (foo);
}
}
}
// response alerts
[{"id":"1","name":"Pepsodent 100g","selling_price":"28.75"},{"id":"2","name":"Pepsodent 40g","selling_price":"18.90"},{"id":"3","name":"Pepsodent brush","selling_price":"19.50"}]