string

std::string == operator not working

Hello, I've been using std::string's == operator for years on windows and linux. Now I am compiling one of my libraries on linux, it uses == heavily. On linux the following function fails, because the == returns false even when the strings are equal (case sensitive wise equal) const Data* DataBase::getDataByName( const std::string& na...

When I create a new String in Java, is it initialized with null or with " "?

Here's my test code: String foo = new String(); System.out.println(foo); The output is blank and a new line is written. Since I'm new to Java, I don't know whether it made a " " string, or nulls are handled as blank lines. ...

Best way to code this, string to map conversion in Groovy

I have a string like def data = "session=234567893egshdjchasd&userId=12345673456&timeOut=1800000" I want to convert it to a map ["session", 234567893egshdjchasd] ["userId", 12345673456] ["timeout", 1800000] This is the current way I am doing it, def map = [:] data.splitEachLine("&"){ it.each{ x -> def object = x.s...

String labels on boxplot outliers

Hi! I want to put string labels on outliers in a boxplot. Here's a simplification of the dataset I'm using: [,x] [,y] [,z] 7 2 a 10 2 b 112 3 c boxdata<-boxplot(x ~ y) To put values as label on outliers by group, I use this function: for(i in 1:length(boxdata$group)){ text(boxdata$group[i]...

How do I keep a count of undefined strings within a loop using PHP?

I'm using a loop to try to generate keyword combinations and also find the ones that have been used the most. The loop finds all the records in the "posts" table where keyword = "chicago". Within this loop, I need to generate strings. Which, would look something like "chicago bulls" "chicago bears" "chicago cubs" etc... How do I tempo...

get last 5 character vb.net

i want to get the last 5 digits/strings from a strings of words. eg: "I will be going to school in 2011!" i am using visual studio.net 2008 and using vb.net. i will like to get "2011!" note, my strings changes, and the last 5 characters can be anything! any ideas. i know visual basic have Right(string, 5); this didn't work for me ga...

using an alternative string quotation syntax in python

Just wondering... I find using escape characters too distracting. I'd rather do something like this: >>> print ^'Let's begin and end with sets of unlikely 2 chars and bingo!'^ Let's begin and end with sets of unlikely 2 chars and bingo! Note the ' inside the string, and how this syntax would have no issue with it, or whatever else i...

Repeated regular expression

How can I parse a strings like : name1="val1" name2="val2" name3="val3" I cannot use split(\s+) as it can be name = "val 1". I am doing java but any laguage is okay. ...

parsing a string of ascii text into separate variables

Hi there, I have a piece of text that gets handed to me like: here is line one\n\nhere is line two\n\nhere is line three What I would like to do is break this string up into three separate variables. I'm not quite sure how one would go about accomplishing this in python. Thanks for any help, jml ...

How to check if letter is upper or lower in PHP?

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? ...

parsing a string based on specified identifiers

Let's say that I have the following text: input = "one aaa and bbb two bbbb er ... // three cccc" I would like to parse this into a group of variables that contain criteria = ["one", "two", "three"] v1,v2,v3 = input.split(criteria) I know that the example above won't work, but is there some utility in python that would allow me to...

Split large text string into variable length strings without breaking words and keeping linebreaks and spaces

I am trying to break a large string of text into several smaller strings of text and define each smaller text strings max length to be different. for example: "The quick brown fox jumped over the red fence. The blue dog dug under the fence." I would like to have code that can split this into smaller lines and have the first li...

How do I prevent buffer overflow converting a double to char?

I'm converting a double to a char string: char txt[10]; double num; num = 45.344322345 sprintf(txt, "%.1f", num); and using ".1f" to truncate the decimal places, to the tenths digit. i.e. - txt contains 45.3 I usually use precision in sprintf to ensure the char buffer is not overflowed. How can I do that here also truncating the de...

Creating a Function in SQL Server with a Phone Number as a parameter and returns a Random Number

Hi Guys, I am hoping someone can help me here as google is not being as forthcoming as I would have liked. I am relatively new to SQL Server and so this is the first function I have set myself to do. The outline of the function is that it has a Phone number varchar(15) as a parameter, it checks that this number is a proper number, i.e....

Complex pattern replacement using PHP preg_replace function ignoring quoted strings

Consider the following string: this is a STRING WHERE some keywords ARE available. 'i need TO format the KEYWORDS from the STRING' In the above string keywords are STRING and WHERE Now i need to get an output as follows: this is a <b>STRING</b> <b>WHERE</b> some keywords ARE available. 'i need TO format the KEYWORDS from the ...

search and display string from group of string php

hi i want to know how to search and display string from group of string like google display the word which we search... the following example from google search word is google books result Search and preview millions of books from libraries and publishers worldwide using Google Book Search. Discover a new favorite or unearth an old ...

C++ String tokenisation from 3D .obj files

I'm pretty new to C++ and was looking for a good way to pull the data out of this line. A sample line that I might need to tokenise is f 11/65/11 16/70/16 17/69/17 I have a tokenisation method that splits strings into a vector as delimited by a string which may be useful static void Tokenise(const string& str, vector<string>& tokens,...

Reading ini file in C#

I am trying to read an ini file that has the following format: SETTING=VALUE SETTING2=VALUE2 I currently have the following code: string cache = sr.ReadToEnd(); string[] splitCache = cache.Split(new string[] {"\n", "\r\n"}, StringSplitOptions.RemoveEmptyEntries); Which gives me a list of settings, however, what...

Number representation problem in php

Hi everybody, It is a simple thing but i don't get answer for that. I am generated auto generation id concatenate with year 100001, 100002 like that, in this 10 is year 0001 is auto generation numbers. When i split the year and number then getting add one value is 2 for 0001. but i need as 0002. Adding value is 0001+1, 0002+1, 0010+...

PHP Filter from string

Hi, I have a string in PHP for example $string = "Blabla [word]"; I would like to filter the word between the '[' brackets. The result should be like this $substring = "word"; thanks ...