string

Get Specific part of a String in Javascript

I have a string containing something like this "Hello bla bla bla bla ok, once more bla können. // this is static: it doesn't change This is a text, this also a text. // this is dynamically added text it can change each time My name mysurename // this is also static text www.blabla.com " Now I have content and I have to get the ...

Enumerating a string

I have a status which is stored as a string of a set length, either in a file or a database. I'm looking to enumerate the possible status' I have the following type to define the possible status' Type TStatus = (fsNormal = Ord('N'),fsEditedOnScreen = Ord('O'), fsMissing = Ord('M'),fsEstimated = Ord('E'),fsSuspect = Ord...

C++/STL string: How to mimic regex like function with wildcards ?

Hello, I would like to compare 4 character string using wildcards. For example: std::string wildcards[]= {"H? ", "RH? ", "H[0-5] "}; /*in the last one I need to check if string is "H0 ",..., and "H5 " */ Is it possible to manage to realize only by STL? Thanks, Arman. EDIT: Can we do it without boost.regex? Or should I add y...

How to cut a string variable into more?

So I've a string: string x = "DR\nDC\nDD"; I want to get each line in a separated variable like this: string y1 = "DR"; String y2 = "DC"; String y3 = "DD"; How can I do that?. ...

How can I use python itertools.groupby() to group a list of strings by their first character?

I have a list of strings similar to this list: tags = ('apples', 'apricots', 'oranges', 'pears', 'peaches') How should I go about grouping this list by the first character in each string using itertools.groupby()? How should I supply the 'key' argument required by itertools.groupby()? ...

When getting substring in .Net, does the new string reference the same original string data or does the data get copied?

Assuming I have the following strings: string str1 = "Hello World!"; string str2 = str1.SubString(6, 5); // "World" I am hoping that in the above example str2 does not copy "World", but simply ends up being a new string that points to the same memory space only that it starts with an offset of 6 and a length of 5. In actuality I am...

Delphi - Differences between CompareStr and CompareString

Hi all, I'm hoping someone can shed some light on this for me> What are the differences, in Delphi 2009, between the CompareStr (defined in SysUtils) and CompareString (from Windows API) functions? Both let you specify the locale to be used, is the Windows one simply more "complete", due to the available comparison flags? Is one conse...

string reverse without new array

hi can anybody tell me the error in this? #include<stdio.h> int main() { char a[]="abcdefgh"; int i=0; int n=strlen(a); char *first; char *second; char *c; *first=a[0]; *second=a[7]; for(i=0;i<=n/2;i++) { *c=*first; *first=*second; *second=*c; first...

How can I write a regular expression that will not match if a string contains a particular substring?

Example: Suppose in the following example I want to match strings that do not contain the word "NOOOT". Example A: This shirt is NOOOT black. Example B: This shirt is black. I want something a little bit like the like the non-matching character class (e.g. [^abc]), but for whole strings: .*?(^NOOOT).*? Does such a creature exist? ...

find the numerical value exist in the Expression C#

How do I find: string str="(120)(1500)x"; How to find out in the event that the string contains: string str1="()()X"; I then have to print: console.writeline("str1 doesnt contain a numerical"); ...

c# string format issue

Hi guys I need to convert a string to a monetary format of {###}.###.###,## that is a value of 5461497702600 would become 54.614.977.026,00 The numbers become excessively large. I am using return string.Format("{0:#" + (val < 1000 ? "" : "\\.") + "##0.00}", val); which returns for the example 54614977.026,00 (only one dot) ...

How to get first word of a sentence in PHP?

hi, i want only the first word of a variable.. example input: <?php $myvalue = 'Test me more'; ?> the output should only "Test", the first word of the input.. how can i do this? ...

Parsing number value from SEF url in PHP

I have SEF urls like /sitename/section/12-news-title and number 12 is id of the news. I need to get that number 12 in my php code, is there any out of the box method in PHP for this? ...

C++ string.substr() function problem

I want to make a program that will read some number in string format and output it like this: if the number is 12345 it should then output 12 23 34 45 . I tried using the substr() function from the c++ string library, but it gives me strange results - it outputs 1 23 345 45 instead of the expected result. Why ? #include <iostream> #incl...

How will you sort strings in the following example ?

so i have a list of string {test,testertest,testing,tester,testingtest} I want to sort it in descending order .. how do u sort strings in general ? Is it based on the length or is it character by character ?? how would it be in the example above ?? I want to sort them in a descending way. ...

C++ Stringstream int to string but returns null

Hi below is my function: string Employee::get_print(void) { string out_string; stringstream ss; ss << e_id << " " << type << endl; out_string = ss.str(); return out_string; } e_id and type are int and they contain values from the class Employee. But when I pass them into the stringstream they just clear the string wh...

Maximum length of a std::basic_string<_CharT> string

Hey all, I was wondering how one can fix an upper limit for the length of a string (in C++) for a given platform. I scrutinized a lot of libraries, and most of them define it arbitrarily. The GNU C++ STL (the one with experimental C++0x features) has quite a definition: size_t npos = size_t(-1); /*!< The maximum value that can be stor...

Is there any way to modify a column before it is ordered in MySQL?

I have a table with a field value which is a varchar(255). The contents of the field can be quite varied: $1.20 $2994 $56 + tax (This one can be ignored or truncated to $56 if necessary) I have a query constructed: SELECT value FROM unnamed_table ORDER BY value However, this of course uses ASCII string comparison to order the resu...

How to delete part of a string in actionscript?

So my string is something like "BlaBlaBlaDDDaaa2aaa345" I want to get rid of its sub string which is "BlaBlaBlaDDD" so the result of operation will be a string "aaa2aaa345" How to perform such thing with actionscript? ...

How to return a string literal from a function

Hi, I am always confused about return a string literal or a string from a function. I was told that there might be memory leak because you don't know when the memory will be deleted? For example, in the code below, how to implement foo() so as to make the output of the code is "Hello World"? void foo ( ) // you can a...