string

How to replace the some characters from the end of a string?

My question is very simple, but I didn't get the answer from google. There is a python string: s = "123123" I want to replace the last 2 with x. Suppose there is a method called replace_last: r = replace_last(s, '2', 'x') print r 1231x3 Is there any built-in or easy method to do this? UPDATE Sorry, guys, since someone said...

How to split text value into array with words in C#?

Is it possible to save value of txtSearche in array splitted into seperate words? txtSearche = "put returns between paragraphs"; something like this: StringBuilder sb = new StringBuilder(txtSearche); array1 = sb[1] = put array2 = sb[2] = returns array3 = sb[3] array4 = sb[4] array5 = sb[5] how to do it correct? ...

How to build Acronyms of a phrase in PHP

Hi I'm looking for a way that I can extract the first letter of each word from an input field and place it into a variable. Example: if the input field is "Stack-Overflow Questions Tags Users" then the output for the variable should be something like "SOQTU" Any help is appreciated. Thanks ...

Find where and which word matched sql LIKE statement

I am using a very long like query to detect offensive words within my users usernames. I have made a moderator page where the moderator can click a button next to the detected username and it will replace the offending word with *'s. The problem is how can I easily detect which offensive word and where to replace? I guess I would need...

double to string formatting

Hi, I have a Double value xx.yyy and I want to convert to string "xxyyy" or "-xxyy", if the value is negative. How could I do it? Regards. ...

C#: Are string.Equals() and == operator really same?

Are they really same? Today, I ran into this problem. Here is the dump from the Immediate Window: ?s "Category" ?tvi.Header "Category" ?s == tvi.Header false ?s.Equals(tvi.Header) true ?s == tvi.Header.ToString() true So, both s and tvi.Header contain "Category", but == returns false and Equals returns true. s is defined as...

Multiple explode characters with comma and - (hyphen)

I want to explode a string for all: whitespaces (\n \t etc) comma hyphen (small dash). Like this >> - But this does not work: $keywords = explode("\n\t\r\a,-", "my string"); How to do that? ...

Parsing 'time string' with Python?

I'm writing an application that involves having users enter time's in the following format: 1m30s # 1 Minute, 30 Seconds 3m15s # 3 Minutes, 15 Seconds 2m25s # 2 Minutes, 25 Seconds 2m # 2 Minutes 55s # 55 Seconds The data can have a single "minute designation", a single "second designation", or both. What is the proper way ...

iPhone .string files

Can someone explain to me how .string files can be used in iPhone SDK similar to how .plist files can be converted into NSDictionaries? Edit: I want to be able to use it like this: NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:@"dict.plist"]; NS???? *strings = [[NS???? alloc] initWithContentsOfFile:@"Strings.strin...

How to manipulate strings with x86 assembly?

I'm in the process of writing an assembly program that takes two strings as input and concatenates them. Here's what I have: (using NASM syntax) SECTION .data hello: db "Hello ",0 world: db "world!",0 SECTION .text ; do the concatenation Since I've never done any work with strings in x86 assembly before, I need to know how...

string ToUpper() function with ToString()

Hi, I have used a string in C# where i am using C# in Visual studio 2008. I wanted to convert it to uppercase. string lowerString = txtCheck.Text; string upperString = lowerString.ToUpper(); Normally this is how i should have used, But the thing is i didn't get any error when i used it like this string upperString = lowerString.ToUp...

My regex is causing a stack overflow in Java; what am I missing?

I am attempting to use a regular expression with Scanner to match a string from a file. The regex works with all of the contents of the file except for this line: DNA="ITTTAITATIATYAAAYIYI[....]ITYTYITTIYAIAIYIT" in the actual file, the ellipsis represents several thousand more characters. When the loop that reads the file arrives on...

How to replace the text that was already exists in a text file and how can i insert text in between the lines of the existing text

Hi all i have a text file saved with some data as follows 101011111111101111111111009100954A094101 9000000000001000000000000000000000000000001000000000000000000000000000000000000000000000000000 Now i would like to insert data in between these 2 lines as 52201 1 ...

Efficient search for shortest and longest strings from an array of long strings in C

Given an array of pointers to ordinary C NUL-terminated (and typically very long) strings, how can we best find the smallest and the largest strings? ...

php search string for latin characters

Hi, I am reading a database and i want to find if the field title contains only latin characters, numbers and any special character. I know that regular expression must be used but i am not very good at reg exp. Can anyone help. ...

filter specific string in php

hello i have string like $var="UseCountry=1 UseCountryDefault=1 UseState=1 UseStateDefault=1 UseLocality=1 UseLocalityDefault=1 cantidad_productos=5 expireDays=5 apikey=ABQIAAAAFHktBEXrHnX108wOdzd3aBTupK1kJuoJNBHuh0laPBvYXhjzZxR0qkeXcGC_0Dxf4UMhkR7ZNb04dQ distancia=15 AutoCoord=1 user_add_locality=0 SaveContactForm=0 ShowVoteRating=0 Li...

How do you use a string as an Index?

Morning. Issue:I have a class called Reports. Two constructors. One allows no parameters, the other a string array. The string array is supposed to be the reports they'd like to display. What I'd like to do is the following: string strSQL = this.Queries[strReportName]; I have a feeling it's possible because in the dataGridView I'...

Grab x number of words before and after a given keyword?

How can I go about grabbing [x] number of words before and after a given keyword in a string in PHP? I am trying to tokenize results from a mysql query tailored to the keyword as a snippet. ...

RegEx to Remove Unwanted text

I'm still kind of new to RegEx in general. I'm trying to retrieve the names from a field so I can split them for further use (using Pentaho Data Integration/Kettle for the data extraction). Here's an example of the string I'm given: CN=Name One/OU=Site/O=Domain;CN=Name Two/OU=Site/O=Domain;CN=Name Three/OU=Site/O=Domain I would like...

Given a list of words, make a subset of phrases with them

What is the best way performance wise to take a list of words and turn them into phrases in python. words = ["hey","there","stack","overflow"] print magicFunction(words) >>> ["hey","there","stack","overflow", "hey there stack","hey there", "there stack overflow","there stack", "stack overflow", "hey there stack overflow" ] Order does...