string

String Enumuration value modified

hi I have one doubt in string . How can we acess the memory of string? is String is reference type or Value type? 1) if it is Reference type then do the following code List<String> strLst = new List<string>() { "abc","def","12"}; strLst.ForEach(delegate(string s) { if (s == "12") { s = "wser"...

I'm new to C, can someone explain why the size of this string can change?

I have never really done much C but am starting to play around with it. I am writing little snippets like the one below to try to understand the usage and behaviour of key constructs/functions in C. The one below I wrote trying to understand the difference between char* string and char string[] and how then lengths of strings work. Furth...

C# I want to check if a string contains one of 10 characters, what is the best way?

I'm using C# and I want to check if a string contains one of ten characters, *, &, # etc etc. What is the best way? ...

Rabin-Karp Algorithm in PHP

Hey people! I was wondering if anyone can share a source for Rabin-Karp algorithm? Thanks ...

Is compile-time "strlen()" effective?

Sometimes it necessary to compary a string's length with a constant. For example: if ( line.length() > 2 ) { // Do something... } But I trying to avoid using "magic" constants in code. Usually I use such code: if ( line.length() > strlen("[]") ) { // Do something... } It more readable, but not efficient because of function ca...

how to convert string to Charsequence in JAVA

how to convert string to Charsequence in JAVA...???? ...

Sizeof string literal

The following code #include <iostream> using namespace std; int main() { const char* const foo = "f"; const char bar[] = "b"; cout << "sizeof(string literal) = " << sizeof( "f" ) << endl; cout << "sizeof(const char* const) = " << sizeof( foo ) << endl; cout << "sizeof(const char[]) = " << sizeof( bar ) << endl; ...

Strip everything but text from html

Hi Our CMS allows users to enter text using a html editor, so when reading text into the webpage I can text like this: &#xD;&#xA; <p>&#xD;&#xA; <strong>text text. more text</strong>&#xD;&#xA; <a href="http://blabla&gt;blabla&lt;/a&gt; even more text... How can I strip everything but text including , and . and similar cha...

How to center a string in elisp?

I would like to center justify a given input string to a given size so that what is produced is a string with padded spaces either side (left and right) of the input string. The code I have to do this: (defun center-string (string size) (let* ((padding (/ (- size (length string)) 2)) (lpad (+ (length string) padding)) ...

What is the correct way to compare char ignoring case?

I'm wondering what the correct way to compare two characters ignoring case that will work for all cultures. Also, is Comparer<char>.Default the best way to test two characters without ignoring case? Does this work for surrogate-pairs? EDIT: Added sample IComparer<char> implementation If this helps anyone this is what I've decided to us...

How to check if a string contains http:// at the start

I want to be able to check a string to see if it has http:// at the start and if not to add it. if (regex expression){ string = "http://"+string; } Does anyone know the regex expression to use? ...

DotNET String comparisons

After a few harsh lessons I now always use OrdinalIgnoreCase when comparing Strings in DotNET. I've run into maybe 5 different problems to do with numerics, weird alphabets and localisations. Does anyone know of a good site that explains in depth a lot of the problems with culture specific Strings, preferably with a bunch of good example...

Split ByteString on a ByteString (instead of a Word8 or Char)

I know I already have the Haskell Data.ByteString.Lazy function to split a CSV on a single character, such as: split :: Word8 -> ByteString -> [ByteString] But I want to split on a multi-character ByteString (like splitting on a String instead of a Char): split :: ByteString -> ByteString -> [ByteString] I have multi-character sepa...

How do the new string types work in Delphi 2009/2010?

I have to convert a large legacy application to Delphi 2009 which uses strings, AnsiStrings, WideStrings and UTF8 data all over the place and I have a hard time to understand how the new string types work and how they should be used. The application fully supported Unicode using TntUnicodeControls and there are 3rd party DLLs which requ...

Count occurances in string from keyword array in javascript

I have an array: var locations = ['Afghanistan','Albania','Algeria','New York']; and a string: var string = 'I love Afghanistan New York Afghanistan Andorra Andorra Algeria New York'; I want to count the number of times each keyword in the array appears in the string but can't figure out the best way to do that. ...

javascript regex to match characters between two strings

Hey Folks, I am entirely new to regex, and am trying to use it to match vales in order to map them to variables (javascript looking at the output in responceText generated from a php script). At the moment I have this code: if (xmlhttp.readyState==4) { document.getElementById("test").innerHTML=xmlhttp.responseText; cmake = xmlh...

Weird OpenEdge query behaviour

We have recently had to do some work with an OpenEdge database that a third party product uses, and today (after much hair-pulling), we finally identified why a view was returning no results. This view in question combines about 100 separate tables, and is then queried against (we have limited rights to this database). One of the fields ...

Optimize regex replace in PHP

I have written a PHP function to take a video embed code that has width and a height and allow you to specify a new width. The function will then scale down the height using the appropriate scaling factor. I discovered that the width and height were not always adjacent so I make a couple of calls which I have a hunch are unnecessary. Is...

hide password in string

I am making a custom ftp client that logs onto a single ftp site and goes to a specific folder to avoid users' putting files in the wrong place. I'm not super concerned about it, but the password is just a string to initiate the new ftp object. FtpClient ftp = new FtpClient("www.markonsolutions.com", "user", "password"); What is the ...

How do I right-align my text in Python?

I have some data that I am displaying in 3 column format, of the form "key: value key: key: value key: value". Here's an example: p: 1 sl: 10 afy: 4 q: 12 lg: 10 kla: 3 r: 0 kl: 10 klw: 3 s: 67 vw: 9 jes: 3 t: 16 uw: 9 skw: 3 u: 47 ug: 9 mjl: 3 v: 37 mj: 8 lza: 3 w: 119 fv: 8 fxg: 3 x: 16 fl: 8 aew: 3...