string-manipulation

Asp.NET - Strip HTML Tags

Using Asp.NET, how do I strip the HTML tags from a given string reliably (i.e. not using regex)? Like PHP's strip_tags. Example: for the string: "<ul><li>Hello</li></ul>" return "Hello". I didn't want to write some kind of parser, so I looked for it on the stardand library, but couldn't find anything. Thanks! ...

php string parse with look ahead

I have this string in PHP: $string = "name=Shake & Bake&difficulty=easy"; For which I want to parse into array: Array ( [name] => Shake & Bake [difficulty] => easy ) NOT: Array ( [name] => Shake [difficulty] => easy ) What is the most efficient way to do this ? ...

jQuery String Contains Manipulation?

In most languages like C# for example given a string you can test (boolean) if that string contains another string, basically a subset of that string. string x = test2; if(x.contains("test")) // do something How can I do this in a simple way with Javascript/Jquery? ...

How to limit string word count in XSLT 1.0?

How can I limit a string's word count in XSLT 1.0? ...

string.Format throws System.Format exception on HTML + javascript

I'm running string.Format on a readonly string that contains a bit of HTML + javascript but I get a System.FormatException instead. This is my format string: <script type="text/javascript"> function {0}_showHideFieldWindow() { if ({0}.IsCustomizationWindowVisible()) { {0}.HideCustomizationWindow(); } els...

c++ Reading X bytes from std::cin, and truncating strings to X byte length

I have a c++ program that takes input from a linux pipe, and outputs to std::cout for further processing. Currently my code looks like this: std::istreambuf_iterator<char> it(std::cin); std::istreambuf_iterator<char> end; std::string str(it, end); //Lots of string manipulation here. str = str.substr(0, 65535); std::cout << str << std...

Splitting a String into Smaller Parts based on Parens

Using java I am trying to develop a method using recursion to analyze a String of the form: (PART0(PART1(PART2)(PART3))) I want the method to split apart the relevant Strings. I want this method to give me the ability to perform some logic on each part of the String without the parentheses being involved in this order: PART2 PART3 P...

Fast open source checksum for small strings

I need a quick checksum (as fast as possilbe) for small strings (20-500 chars). I need the source code and that must be small! (about 100 LOC max) If it could generate strings in Base32/64. (or something similar) it would be perfect. Basically the checksums cannot use any "bad" chars.. you know.. the usual (){}[].,;:/+-\| etc Clarifi...

Removal of ¶ (pilcrow) from pasted text

Users are pasting text from Lotus Notes into my VBA application. This is then being stored in Access. Sometimes the pasted text includes what I assume is a carriage return which, when pasted into a single line form control, is displayed in the application's forms as ¶. However, as this won't paste in to the VBE, I am unable to add thi...

Overcoming the Bitap algorithm's search pattern length

I am new to the field of approximate string matching. I am exploring uses for the Bitap algorithm, but so far its limited pattern length has me troubled. I am working with Flash, and I dispose of 32 bit unsigned integers and a IEEE-754 double-precision floating-point Number type, which can devote up to 53 bites for integers. Still, I wo...

Is there a better way than String.Replace to remove backspaces from a string?

I have a string read from another source such as "\b\bfoo\bx". In this case, it would translate to the word "fox" as the first 2 \b's are ignored, and the last 'o' is erased, and then replaced with 'x'. Also another case would be "patt\b\b\b\b\b\b\b\b\b\bfoo" should be translated to "foo" I have come up with something using String.Repla...

Can you do HtmlDecode & HtmlEncode in Silverlight?

So since System.Web & HttpContext isn't available in Silverlight is there a way to do HtmlDecode & HtmlEncode inside a Silverlight app without some horrendous Regex? ...

Find/Replace Word Puzzle

Let's say I have an object that contains a Word property and a Sentence property. The sentence must use the word, and I want to replace the word in that sentence with a link using a public function (say, GetLinkedSentence). The catch is maybe the sentence uses a plural form of the word and maybe the "word" itself is actually a phrase, or...

HTML Escaping - Reg expressions?

I'd like to HTML escape a specific phrase automatically and logically that is currently a statement with words highlighted with quotation marks. Within the statement, quotation or inch marks could also be used to describe a distance. The phrase could be: Paul said "It missed us by about a foot". In fact it was only about 9". T...

Inverse String.Replace - Faster way of doing it?

I have a method to replace every character except those I specify. For example, ReplaceNot("test. stop; or, not", ".;/\\".ToCharArray(), '*'); would return "****.*****;***,****". Now, this is not an instance of premature optimization. I call this method quite a few times during a network operation. I found that on longer strings...

Testing for repeated characters in a string

I'm doing some work with strings, and I have a scenario where I need to determine if a string (usually a small one < 10 characters) contains repeated characters. `ABCDE` // does not contain repeats `AABCD` // does contain repeats, ie A is repeated I can loop through the string.ToCharArray() and test each character against every oth...

Cutting HTML strings without breaking HTML tags

How to write a function that can cut a string with HTML tags to an N-length string without breaking HTML tags while doing it. The returned string doesn't need to be exactly N characters long. It can cut it before or after tag that is on the edge of N-long string. Visit <a href="www.htz.hr">Croatia</a> this summer. CutIt(9) should re...

VBA Trim() function truncating text oddly!

I'm trying to trim extraneous white space at the end of a memo field in MS Access. I've tried doing it a number of ways: 1) an update query with the field being updated to Trim([fieldname]). For some reason, that doesn't do anything. The whitespace is still there. 2) an update using a Macro function in which the field contents are p...

Javascript multiple replace

How do you replace all instances of one string with another in javascript? Example: someString = 'the cat looks like a cat' anotherString = someString.replace('cat', 'dog'); results in anotherString being set to 'the dog looks like a cat', and I would like it to be 'the dog looks like a dog' ...

PHP Remove a single letter from a long string only once?

I need to remove a single character from a string, eg in the text block below I would need to be able to remove ONE of the j's. djriojnrwadoiaushd leaving: driojnrwadoiaushd ...