string

How can I end a string randomly and concate another string at the end in Python?

Basicaly I have a user inputted string like: "hi my name is bob" what I would like to do is have my program randomly pick a new ending of the string and end it with my specified ending. For example: "hi my name DUR." "hi mDUR." etc etc I'm kinda new to python so hopefully there's an easy solution to this hehe ...

Substring outofindex

I wrote a code for which if 23E+20 is the input then output should be 230000000(20 zeros) if 4.456E-14 is the input then 4.456000(14 zeros) should be the output But its not working properly. Please let me know where I did error. Thank You. using System; class test { public static void Main() { Console.WriteLine("Enter double"); ...

Reversing words in a string

Hello, does anybody know how can I sort words in string using javascript, jquery. For example I have this: var words = "1 3 2" Now I want to reverse it to this: var words = "2 3 1" Thanks ...

php transforming a specific string into array values

hi, i get this response from the server: OK: 0; Sent queued message ID: e3674786a1c5f7a1 SMSGlobalMsgID:6162865783958235 OK: 0; Sent queued message ID: 9589936487b8d0a1 SMSGlobalMsgID:6141138716371692 and so on... This is just one long string with NO carriage return i copied it exactly as received. please note, initial OK can be a...

Get part of string into variable

Hello, i need to get part of string into variable. (note, i will always use exactly 4 names) var names = "Andrew Peter Bob Mark" I need to get the last one to var last = "Mark" Thanks for help in advance ...

Working with Unicode strings in Delphi 7

I need to write a program which will browse through strings of various lengths and select only those which are written using symbols from set defined by me (particularly Japanese letters). Strings will contain words written in different languages (German, French, Arabic, Russian, English etc). Obviously there is huge number of possible c...

Error #1010 actionscript 3

The counter displays sprites in place of number values. More experienced programmers have given me a clue. Why am I getting error # 1010. Secondly, what am I not seeing that's so obvious? I wish I went in to this with a better foundation in actionscript 3, but I'm reading and doing my best. WHAT I SEE -dollar sign indicates a variabl...

strcmp for python or how to sort substrings efficiently (without copy) when building a suffix array

Here's a very simple way to build an suffix array from a string in python: def sort_offsets(a, b): return cmp(content[a:], content[b:]) content = "foobar baz foo" suffix_array.sort(cmp=sort_offsets) print suffix_array [6, 10, 4, 8, 3, 7, 11, 0, 13, 2, 12, 1, 5, 9] However, "content[a:]" makes a copy of content, which becomes very...

java replaceLast()

Is there replaceLast() in Java? I saw there is replaceFirst() EDIT: If there is not in the SDK, what would be a good implementation? ...

C# pattern matching

Hi guys, I am bit new to c#, i am looking for a string matching pattern to do the following, I have a string like this The book will be showcased at a reception in Number 11 Downing Street and will be attended by key healthcare i need to create a span tag to highlight some text fragments using startIndex and length, for an...

PHP - smart, error tolerating string comparison

Hello, I'm looking either for routine or way to look for error tolerating string comparison. Let's say, we have test string Čakánka - yes, it contains CE characters. Now, I want to accept any of following strings as OK: cakanka cákanká ČaKaNKA CAKANKA CAAKNKA CKAANKA cakakNa The problem is, that I often switch letters in word, and...

What is the point of having string resources in C++?

I've never used string resources before so I would like to ask, when should I use them and why are they beneficial when I can just define a string? ...

Regarding String If Condition

I have a lot of static values "ABC" , "DEF" , "FGH" ,"IJK", "JKL" I want to have an if condition that checks whether the a String variable exists in this list of static values. I dont want to have too many or conditions. what is a better way of doing it? ...

How to replace 2 strings (with eachother) simultaneously in PHP

What I'm trying to do is very simple, but I'm looking to do it most efficiently, preferably using php builtin fns. $str = '1234'; echo replace_function(array('1','3'),array('3','1'),$str); // output: 3214 str_replace,preg_replace would result in 1214, which means it goes through the arrays, replacing matched strings. I'm looking for ...

php merging two arrays into one

hi, I have two arrays that need to be merged together and trying to figure out the correct way of doing it. this is the first array Array ( [IndividualOutmsg] => Array ( [0] => Array ( [user_id] => 3 [number] => 414566765 ...

Why am I getting a segmentation fault with this code?

What ever could be the problem with it? #include <stdio.h> #include <string.h> #define SIZE 19 void filePrint(char fileName[]); int main (void) { char fileRead[SIZE]; filePrint(fileRead); return 0; } void filePrint(char fileName[]) { FILE *inp; int input_status = 0; char readFile[SIZE]; inp = fopen(fileName, "...

Formatting alphanumeric string

Hello. I have a string with 16 alphanumeric characters, e.g. F4194E7CC775F003. I'd like to format it as F419-4E7C-C775-F003. I tried using string.Format("{0:####-####-####-####}","F4194E7CC775F003"); but this doesn't work since it's not a numeric value. So I came up with the following: public class DashFormatter : IFormatProvider, ...

Java: string tokenizer and assign to 2 variables?

Hi, Let's say I have a time hh:mm (eg. 11:22) and I want to use a string tokenizer to split. However, after it's split I am able to get for example: 11 and next line 22. But how do I assign 11 to a variable name "hour" and another variable name "min"? Also another question. How do I round up a number? Even if it's 2.1 I want it to rou...

Using of Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex with string[]

Hi I'm currently using Zend_Soap_AutoDiscover to generate my WSDL file, the problem is I want this wsdl to handle output of type ArrayOfString ( string[] ). so I changed the complex type strategy to Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence, it works properly but the problem is that the output isn't really an array of string the outpu...

Copy const char*

Hello, I'm receiving a c-string as a parameter from a function, but the argument I receive is going to be destroyed later. So I want to make a copy of it. Here's what I mean: class MyClass { private: const char *filename; public: void func (const char *_filename); } void MyClass::func (const char *_filename) { filename = _filenam...