string-manipulation

Replacing a specific substring with another substring in a string in SQL stored procedure

Hello all, I've the following requirement. I'm passing 'ABC DEF' as a command parameter @MyString to a stored procedure. In the stored procedure level i need to replace the substring DEF with XYZ to get the string 'ABC XYZ'. How can i do that? Thank you. NLV ...

date string formatting

The best way to take a string that is formated like... YYYY-MM-DD and make it appear like... MM/DD/YYYY The reason it is not a javascript date object is because I am working with massive amounts of data and these dates are being pulled from a database. I see no need to convert it to a date object. ...

Javascript string replacement - what's the best way to do this?

I have a problem trying to transform a given input string to a given output string using regular expressions in Javascript. I'm not even sure if what I'm trying to accomplish can be done with regular expressions, or would be most efficient using some other means. I'm hoping someone can help: I have the following input string: #> Some...

python file reading

I have file /tmp/gs.pid with content client01: 25778 I would like retrieve the second word from it. ie. 25778. I have tried below code but it didn't work. >>> f=open ("/tmp/gs.pid","r") >>> for line in f: ... word=line.strip().lower() ... print "\n -->" , word ...

Nice way to break a reply up into pieces in ruby

Hello, I'm writing an IRCd. For this topic it doesn't really matter if you know much about IRC. Its a simple code style problem. Quick overview of the problem: No message may be longer than 512 characters If the message is more, it must be broken into pieces The NAMES reply sends all the nicknames of users on a channel, and quickly gr...

C# - Simplest way to remove first occurance of a substring from another string

I need to remove the first (and ONLY the first) occurrence of a string from another string. Here is an example replacing the string "\\Iteration". This: ProjectName\\Iteration\\Release1\\Iteration1 would become this: ProjectName\\Release1\\Iteration1 Here some code that does this: const string removeString = "\\Iteration"; int...

Repeat while changing... stop once change no longer occurs i.e. stabilise value.

I was wondering if there is a nice pattern or better yet a specific function which applies a function until there is no longer a change in it's result. url = "http://www.zzz.com/yyy/lt%255B1%255D.jpg" unescaped = unescape(url) while unescaped != url do url = unescaped unescaped = unescape(unescaped) end Although the code above is ...

Is there "\n" equivalent in VBscript?

I want to use the Replace function in VBScript to replacea all line breaks in a string for "\n". I come from java, so using \n inside a string means a line break. Is there an equivalent in VBScript? ...

Replace Multiple "-" PHP

Possible Duplicate: PHP Preg-Replace more than one underscore Hi, I'm just wondering how I can replace 2 or more - signs in a string with just one in PHP. So like 1-2---3--4 would go to 1-2-3-4 Thanks :) ...

To get Numeric value from a alphanumeric String in PHP?

i want a function or a code to get numeric value from the string whose value is "2008 Revenue $5,700,390,000". the output that i want is $5,700,390,000. ...

How to get rid of extra elements in string literal in php ?

I have number like 9843324+ and now I want to get rid of + at the end and only have 9843324 and so how should I do this in php ? Right now I am doing $customer_id = explode('+',$o_household->getInternalId); also $o_household->getInternalId returns me 9843324+ but I want 9843324, how can I achieve this ? Thanks. ...

Simple but confusing Ruby string manipulation.

I am trying to convert a small bit of Ruby to PHP, and I have had success so far, except for this one line: string = string[16,string.length-16] I have tried these two things in PHP: $string = substr($string, 16, strlen($string) - 16); // and $string = substr($string, 16, strlen($string) - 32); But the problem is that I have no clu...

Reading a line in c# without trimming the line delimiter character

Hi! I've got a string that I want to read line-by-line, but I also need to have the line delimiter character, which StringReader.ReadLine unfortunately trims (unlike in ruby where it is kept). What is the fastest and most robust way to accomplish this? Alternatives I've been thinking about: Reading the input character-by-character an...

what is the better way to search in millions of file names with wildcard(GLOB) support

i am working on a small search engine to display a matching file names with full path. and important thing is that i need to provide wildcard(GLOB) search like *.doc or *list*.xlx or *timesheet* or ???.doc or something like that. i found some related solution http://stackoverflow.com/questions/954752/search-for-strings-matching-the-p...

Does the Python standard library contain a module for manipulating URIs?

I'd like to pass a URI to a constructor and get back an object on which I can call obj.type, obj.host, obj.port, etc. The "Request" object of the urllib2 module is close to what I need, but not quite it. ...

How to get number from a string

I would like to get number from a string eg: My123number gives 123 Similarly varchar(32) gives 32 etc Thanks in Advance. ...

How to get rid of string elements in php ?

Customer id literal has customer_id+Domain_details, eg.: 998787+nl and now I just want to have 998787 and not +nl, how can this be acheived this in php Question: I have number like 9843324+nl and now I want to get rid of all elements including + and afterwards at the end and only have 9843324 and so how should I do this in php ? Right...

Does VBScript have a substring() function?

Is there a substring() function in VBScript similar to Java's string.substring()? ...

translate by replacing words inside existing text

What are common approaches for translating certain words (or expressions) inside a given text, when the text must be reconstructed (with punctuations and everythin.) ? The translation comes from a lookup table, and covers words, collocations, and emoticons like L33t, CUL8R, :-), etc. Simple string search-and-replace is not enough since...

Replace words from a dictionary

I have an array of hashes, each hash has two keys : "from" and "to" @dictionary = [{:to=>"lazy", :from=>"quick"}, {:to=>"flies", :from=>"jumps"}, {:from => "over the", :to => "under the"}] I have some long string @text = "quick brown fox jumps over the lazy dog" How can I replace all occurences of "from" sentences to "to" sentences...