string

storing of strings in char arrays in C

#include<stdio.h> int main() { char a[5]="hello"; puts(a); //prints hello } Why does the code compile correctly? We need six places to store "hello", correct? ...

How to find validity of a string of parentheses, curly brackets and square brackets?

I recently came in contact with this interesting problem. You are given a string containing just the characters '(', ')', '{', '}', '[' and ']', for example, "[{()}]", you need to write a function which will check validity of such an input string, function may be like this: bool isValid(char* s); these brackets have to close in the co...

PostgreSQL String search for partial patterns removing exrtaneous characters

Looking for a simple SQL (PostgreSQL) regular expression or similar solution (maybe soundex) that will allow a flexible search. So that dashes, spaces and such are omitted during the search. As part of the search and only the raw characters are searched in the table.: Currently using: SELECT * FROM Productions WHERE part_no ~* '%sear...

change flex application identifier string

Just wondering how you can go about changing a flex app's application identifier string? I know its located on line 16 of the xml file but every time I change it, an error occurs when I export the release build. Just wondering how I go about doing this. ...

binary_search not working for a vector<string>

#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main(void) { string temp; vector<string> encrypt, decrypt; int i,n, co=0; cin >> n; for(i=0;i<n;i++) { cin >> temp; encrypt.push_back(temp); } for(i=0;i<n;i++) { cin >> temp...

How to test whether a char is NOT in a string? (java, junit)

As title says, im having trouble with my junit tests passing for checking if a character is not in a string and how to check if an empty string doesnt have a character. here is the method i have: public static boolean isThere(String s, char value){ for(int x = 0; x <= s.length(); x++){ if(s.charAt(x) == value){ return true...

strcasecmp in C returns 156 instead of 0, any ideas why?

I have the following code: printf("num: %d\n", strcasecmp(buf, "h\n")); And I get the following results when I try plugging in different letters: a: -7 g: -1 i: 1 j: 2 h: 156 H: 156 Should strcasecmp not return 0 when buf is equal to H or h? Any ideas why it's returning 156? I need to figure out how to check whether the user types ...

Loop over a file and write the next line if a condition is met

Having a hard time fixing this or finding any good hints about it. I'm trying to loop over one file, modify each line slightly, and then loop over a different file. If the line in the second file starts with the line from the first then the following line in the second file should be written to a third file. with open('ids.txt', 'rU') ...

How to replace the characters in fixed positions in PHP?

I want to replace with the 4~8 characters of a string with *,how to do it? HelloWorld => Hell****ld ...

Lose the last 3 chars from string variable

if the last 4 chars in my string(result) are " AND" or the last three chars are " OR" I would like to remove these from the string. So far I have am trying result.trimend and a few other methods but am unsure how to get it working. Thanks ...

Is it a good idea to return " const char * " from a function?

Now I have a function that has to return a string. I saw a particular implementation where he returns a const char * from the function. Something like this: const char * GetSomeString() { ........ return somestlstring.c_str(); } SomeOtherFoo () { const char * tmp = GetSomeString(); string s = tmp; } Now I felt there is...

Non-latin-characters ordering in database with "order by"

I just found some strange behavior of database's "order by" clause. In string comparison, I expected some characters such as '[' and '_' are greater than latin characters/digits such as 'I' or '2' considering their orders in the ASCII table. However, the sorting results from database's "order by" clause is different with my expectation. ...

Python string comparison

Hello all, I have a python function that makes a subprocess call to a shell script that outputs 'true' or 'false'. I'm storing the output from subprocess.communicate() and trying to do return output == 'true' but it returns False every time. I'm not too familiar with python, but reading about string comparisons says you can compare st...

How can I convert this "Tuesday, March 30, 2010 10:45 AM" string to a DateTime practically?

Well, This is a string I get from a web service: "Tuesday, March 30, 2010 10:45 AM" and I need to convert it to a DateTime. Do you know a simple way to achieve this? Thanks, ...

check a string if have a word

I have a string like this: "TEST.DATA.Data.COR.Point,2;TEST.DATA.Data.COR.Point,5;TEST.DATA.Data.COR.Point,12;TEST.DATA.Data.COR.Point,12;TEST.DATA.Data.COR.WordTOFIND,18" I have a list of array with that, but some dont have that wordtofind. My question is - how can I compare the string to check if have that word? ...

In what scenario would one need to use PHPs magic function toString()

Why would a programmer need to use the function? How would the same results have been achieved in php 4? ...

Formatting a date string when the string sits inside another string

Hi, I'm trying to figure out a way to format a date string that sits inside string using javascript. The string can be: "hello there From 2010-03-04 00:00:00.0 to 2010-03-31 00:00:00.0" or "stuff like 2010-03-04 20:00:00.0 and 2010-03-31 00:00:02.0 blah blah" I'd like it to end up like: "stuff like 4 March 2010 and 31 March 2010 ...

Missing backslashes in filename using C#

Hi, I have a string literal as follows: string filename = @"C:\myfolder\myfile.jpg"; When I use File.Exists(filename) it works most of the time but sometimes I get an error saying the following file doesn't exist: C:myfoldermyfile.jpg Something seems to strip the backslashes out of the filename. This code is sometimes accessed vi...

Are strings pooled in Python

Does Python have a pool of all strings and are they (strings) singletons there? More precise, in the following code one or two strings were created in memory: a = str(num) b = str(num) ? ...

need identical string comparison function in php and java

I have sorted list of strings that I move between php and java. to be able to bsearch on this data, I need the same comparison function. any idea what string compare functions I can use that will always give the same result in both? eg php's strcmp() vs java's String.compareTo() yes I know I could make my own string compare that does...