string-manipulation

How can I replace characters from a databound object?

I have this: <img id="imgField" alt="" runat="server" src='<%# string.Format("images/{0}.jpg", DataBinder.Eval(Container.DataItem,"Name")) %>' /> and it's rendering %20's from the spaces in the databound Name. So I need to replace all of the "%20's" with "" I tried <img id="imgField" alt="" runat="server" src='<%# string.Format("ima...

PHP - remove <img> tag from string

Hey, I need to delete all images from a string and I just can't find the right way to do it. Here is what I tryed, but it doesn't work: preg_replace("/<img[^>]+\>/i", "(image) ", $content); echo $content; Any ideas? ...

How do I replace Ê with '' in php?

str_replace('Ê','',$line); Ain't working. Is there some special string that represents that? ...

Why Can't I do String.Replace() on a IO.File.ReadAllText() string?

I am using System.IO.FIle.ReadAllText() to get the contents of some template files that I created for email content. Then I want to do a Replace on certain tokens within the files so I can add dynamic content to the template. Here is the code I have, it seems to me like it should work just fine... Dim confirmUrl As String = Request.App...

How do I get only a determined number of words from a string in php?

Here is what I am trying to do. I have a block of text and I would like to extract the first 50 words from the string without cutting off the words in the middle. That is why I would prefer words opposed to characters, then I could just use a left() function. I know the str_word_count($var) function will return the number of words in ...

How to remove the rest of a string

If i have a string like so: Hello - Bye How can i make php find and delete a specifc character and the rest of the string on wards like an example Hello - Bye find the character - and be left with the string Hello ...

Find all ocurrences of a string in a sequence of strings in F#?

String processing in C# and VB.NET is easy for me, but understanding how to do the same in F# not so easy. I am reading two Apress F# books (Foundations and Expert). Most samples are number crunching and, I think, very little of string manipulation. In particular, samples of seq { sequence-expression } and Lists. I have a C# program I w...

Trim all chars off file name after first "_"

I'd like to trim these purchase order file names (a few examples below) so that everything after the first "_" is omitted. INCOLOR_fc06_NEW.pdf Keep: INCOLOR (write this to db as the VendorID) Remove: _fc08_NEW.pdf NORTHSTAR_sc09.xls Keep: NORTHSTAR (write this to db as the VendorID) Remove: _sc09.xls Our scenario: The managers are ...

C# Strings - Simple syntax Question

Ok, I haven't programmed in C# before but I came upon this code and was wondering what it does. Now, I now that it just searches and find the first occurrence of "." and replaces it with "" but what exactly is in the ""? Would this just delete the period or is there a space character that replaces the "."? I'm trying to figure out how to...

set string to sqlbinary

Hi, I'm having issues with setting a string to sqlbinary or something like that. Example: The string comes from a csv file: 0x0000000001E5CFE7 It's read into string, but now I have to execute a stored procedure with the parameter timestamp, because it's an timestamp. Does anyone have an idea for me how to set this. ...

Most efficient way to remove special characters from string

I want to remove all special characters from a string. Allowed characters are A-Z (uppercase or lowercase), numbers (0-9), underscore (_), or the dot sign (.). I have the following, it works but I suspect (I know!) it's not very efficient: public static string RemoveSpecialCharacters(string str) { StringBuilder sb = ne...

Preg_Match a string in the form of a URL

I have a URL as a string. How do I match the numbers after the VideoID. Also VideoID may occur at different points in the URL. But I will worry about that afterwards, as I can't even do this. $string = 'http://example.com/index.php?action=vids.individual&amp;VideoID=60085484'; preg_match('/(?<VideoID>)=/', $string, $matches); print_r(...

How can I split a comma delimited string into an array in PHP?

I need to split my string input into an array at the commas. How can I go about accomplishing this? Input: 9,[email protected],8 ...

Need some help with python string / slicing operations

This is a very newbie question and i will probably get downvoted for it, but i quite honestly couldn't find the answer after at least an hour googling. I learned how to slice strings based on "exact locations" where you have to know exactly where the word ends. But i did not find any article that explained how do it on "non static" strin...

Fastest way to convert a list of strings into a single concatenated string?

I have some LINQ code that generates a list of strings, like this: var data = from a in someOtherList orderby a select FunctionThatReturnsString(a); How do I convert that list of strings into one big concatenated string? Let's say that data has these entries: "Some " "resulting " "data here." I should end up w...

Is there any equivalent function that returns the character at position `X` in PHP?

Is there any equivalent function that returns the character at position X in PHP? I went through the documentation but couldn't find any. I am looking for something like: $charAtPosition20 = strCharAt(20, $myString); ...

Encoding&compression of URL in PHP

How to easy encode and "compress" URL/e-mail adress to string in PHP? String should be: difficult to decode by user as short as possible (compressed) similar URLs should be different after encoding not in database easy to decode/uncompress by PHP script ex. input -> output, stackoverflow.com/1/ -> "n3uu399", stackoverflow.com/2/ ...

Does anyone have a PHP snippet of code for grabbing the first "sentence" in a string?

If I have a description like: "We prefer questions that can be answered, not just discussed. Provide details. Write clearly and simply." and all I want is "We prefer questions that can be answered, not just discussed." I figure I would search for a regular expression, like "[.!\?]", determine the strpos and then do a substr from the ...

Log file rotation name

I have written this simple C program that changes the rotation file name. Eg: For A_B_C_1 Need to rotate it to A_B_C_2 and if A_B_C need to rotate it to A_B_C_1 Problem is the strncat is not working as expectedly. It is giving me output like: A_B_C_1 (Works fine for single instance) A_B_C_2 A_B_C_23 A_B_C_2324 Logic used is simple...

What's the most common method for exploding a string of tags?

I'm not really concerned about the implementation so much as what the most common method would be. Our users aren't very techy so we get a lot of tags that don't exactly follow directions. I'd rather conform to a greater standard than try to make it up myself. Should we even allow different methods or just accept one delimeter like ", "...