string

PHP replace string

$string = 'http://site.com/category/1/news/2134/'; // '1' is dynamic How can I change 1 to any number I want? Can't call parts of the string, its just a text-like variable. It can be done with some true regex. ...

Strange UTF8 string comparison

Hello guys, I'm having this problem with UTF8 string comparison which I really have no idea about and it starts to give me headache. Please help me out. Basically I have this string from a xml document encoded in UTF8: 'Mina Tidigare anställningar' And when I compare that string with the exactly the same string which I typed myself: 'Mi...

How to find a particular value from a string, PHP

I have a string (not xml ) <headername>X-Mailer-Recptid</headername> <headervalue>15772348</headervalue> </header> from this, i need to get the value 15772348, that is the value of headervalue. How is possible? ...

How can i use a switch with a spinner ?

Hi everyone, so i started android programming like a month ago, and i've got a probleme today. The thing i want to do is : From a Item in the Spinner, when i select it there is a Text View changing on the back. spin.setAdapter(adapter_city); spin.setOnItemClickListener(this); } @Override public void onItemClick(AdapterView<?> p...

Test if a python string is printable

I have some code that pulls data from a com-port and I want to make sure that what I got really is a printable string (i.e. ASCII, maybe UTF-8) before printing it. Is there a function for doing this? The first half dozon places I looked didn't have anything that looks like what I want. (string has printable but I didn't see anything (the...

C# - Checking if strings have this

how can I Check if a string contains another string? ...

Factoring out strings in java using eclipse

Hi, I am trying to factor out strings in my java code. I am using the Eclipse SDK (Galileo) 3.5.2 Version. I tried using the "Externalize Strings" widget of Eclipse. But, I am not getting the expected results. Before Externalizing: package org.libx.libappdatabase; public class StringExternalize { public StringExternalize () { ...

C# - string to keywords

What is the most effecient way to turn string to a list of words in C#? For example: Hello... world 1, this is amazing3,really , amazing! *bla* should turn into the following list: ["Hello", "world", "1", "this", "is", "amazing3", "really", "amazing", "bla"] Note that it should support other languages than English. I need this ...

In VBScript, how to convert a string value into an object like ADODB.Recordset as objects variable name?

As i mentioned in the title, i have a function that retrieves some string parameters. In the function i need a convertion a string to an object like ADODB.Recordset. I am using VBScript in ASP. Thank you My code looks like: Function calc(someString,anotherString) Set someString = Server.CreateObject("ADODB.recordset") 'Opening db ...

C++ String to Double parsing with exceptions?

In java, if I wanted to create some application which could receive both doubles and strings as appropriate input, I would probably do the following: String input = getInput();// try { double foo = Double.valueOf(input); //Do stuff with foo here } catch (NumberFormatException e) { //Do other validation with input } How...

How to use double quotes in a string when using the @ symbol?

I need to use double quotes in a string that uses the @ symbol. Using double quotes is breaking the string. I tried escaping with \, but that doesn't work. Ideas? ...

How to efficiently filter a string against a long list of words in Python/Django?

Stackoverflow implemented its "Related Questions" feature by taking the title of the current question being asked and removing from it the 10,000 most common English words according to Google. The remaining words are then submitted as a fulltext search to find related questions. I want to do something similar in my Django site. What is ...

String comparison order in Java

Are both the String comparison methods below considered to be equal public class TestString { public static final String CONSTVAL="foo"; public boolean testString1(String testVal) { return testVal.equalsIgnoreCase(CONSTVAL); } public boolean testString2(String testVal) { return CONSTVAL.equalsIgnoreCase...

ASP.NET MVC: Why do I get null instead of empty string when receiving POST request?

I used to receive empty string when there was no value: [HttpPost] public ActionResult Add(string text) { // text is "" when there's no value provided by user } But now I'm passing a model [HttpPost] public ActionResult Add(SomeModel Model) { // model.Text is null when there's no value provided by user } So I have to use th...

efficiency in textbox control access vs working on local copy of text.

I was programming a small notepad like app with some extra functionalities. I am using a rich textbox as the main area. My question is while performing operations on the contents of the textbox, like code formatting, highlighting, etc which might require reading each character and replacing wherever necessary. Moving back across text in...

[Actionscript 3] Get the byte length of a string

Is there an easy way to get the byte length of a string in AS3? String.length works in many cases, but breaks if it encounters mulibyte unicode characters. (in this particular case, I need to know this so I can preface messages sent across a TCP socket with the message length. This is in standard netstring format e.g. "length:message,")...

Is there a utility in the Android SDK or in Java to replace parts of a string using placeholders?

It would work something like this someUtility.replace ("Hello, my name is {1}. What is your {2}?", "Mark", "name"); Thanks in advance! ...

iPhone Formatted Strings

I would like to be able to format a string in a label or textfield so that i can change the font color and size of certain keywords. does anyone know how to do this? is it possible to find the actual physical dimensions of a CharcterSet as well? ...

Byte Array to Word Array to String

I have this byte[]: 00 28 00 60 00 30 10 70 00 22 FF FF. I want to combine each pair of bytes into a word: 0028 0060 0030 1070 0022 FFFF. I also want to turn the word array into a string: "0028 0060 0030 1070 0022 FFFF" (without using byte[]). I fixed SLaks code and it works: StringBuilder sb = new StringBuilder(); for(var i = 0; i <...

Counting palindromic substrings in O(n)

Given a string (assume only English characters) S of length n, we can count the number of palindromic substrings with the following algorithm: for i = 0 to |S| do p1 = number of palindromes centered in i (odd length) p2 = number of palindromes centered in i and i+1 (even length) add p1 + p2 to total number of palindromic su...