replace

Replace %20 with spaces when downloading files?

Is it possible to get a url/downloaded file name change the "%20" to spaces? Like instead of downloading the file my%20file.pdf, download my file.pdf? I'd like to use PHP if possible... ...

Backreferences syntax in replacement strings (why dollar sign?)

In Java, and it seems in a few other languages, backreferences in the pattern is preceded by a slash (e.g. \1, \2, \3, etc), but in a replacement string it's preceded by a dollar sign (e.g. $1, $2, $3, and also $0). Here's a snippet to illustrate: System.out.println( "left-right".replaceAll("(.*)-(.*)", "\\2-\\1") // WRONG!!! ); //...

String replace method not doing anything in Flex 4 app

I have a string called userEmail in my Flex 4 app that has a value of: my%40email.com I need to have an @ symbol instead of %40, so I run this line: userEmail.replace("%40","@"); But the string has the same value after. What am I doing wrong? Thanks for reading. ...

Smiley Replace within CDATA of an HTML-String

Hello, i have got a simple problem :( I need to replace text smilies with the according smiley-image. ok.. thats not really complex, but now i have to replace only smilie appereances outside of HTML Tags. short examplae: Text: Thats a good example :/ .. with a <a href="http://www.foobar.com"&gt;link&lt;/a&gt; inside. i want to repla...

How to replace {tag_INDEX} with array[INDEX] element

Hi, I have string like this; "String {tag_0} text {tag_2} and {tag_1}" Now i need to replace all {tag_INDEX} with elements from array $myArray = array('a','b','c'); so after replacement it should looks like: "String a text c and b" What is the best way to do this? I'm trying with preg_replace and preg_replace_call...

Python adding elements from string

I have a string like this "1 1 3 2 1 1 1 2 1 1 1 1 1 1 1 1,5 0,33 0,66 1 0,33 0,66 1 1 2 1 1 2 1 1 2 0,5 0,66 2 1 2 1 1 1 0 1". How to add elements to each other in python ? ...

How do I remove &#13 ; from my text file using VBScript Replace() or a regex?

Hi! I'm doing a conversion between two software which both use XML so the actual conversion part is fairly straightforward - adding text here, removing others here, converting a few information. I'm using VBSCript WSH. The only issue I'm still having is the darn &#13; character - because it's considered an HTML Character, it's not dete...

Remove a character from a given position on Oracle

Is there anyway to remove a character from a given position? Let's say my word is: PANCAKES And I want to remove the 2nd letter (in this case, 'A'), so i want PNCAKES as my return. Translate doesnt work for this. Replace doesnt work for this. Regex is damn complicated... Ideas? ...

JQuery slideToggle replace image src

Hi, This function is called when an up/down arrow is clicked to slide hidden div. If the div is hidden, the arrow points down and changes to up when the div is shown. If the div is shown, the arrow points up to hide div and changes to down when the div is closed. I just wanted to know if there was a more efficient way of doing this or...

mysql replace into alternative

i'm currently using a replace into statement, I have a unique field which will cause it to UPDATE rather than INSERT if it finds a duplicate... Problem is if it finds a duplicate i can't get to update on a few columns, it just wipes the lot. Is there a similar "one statement" method where I can just UPDATE what I want? I've found mer...

JavaScript: how to remove line that contain specific string

hi, how can i remove a complete line if it's contain specific string like #RemoveMe thanks in advance ...

Java how to replace 2 or more spaces with single space in string and delete leading spaces only

Looking for quick, simple way in Java to change this string " hello there " to something that looks like this "hello there" where I replace all those multiple spaces with a single space, except I also want the one or more spaces at the beginning of string to be gone. Something like this gets me partly there String mytext =...

Replacing text with a link in jQuery

I'm trying to replace a small part of text in a large HTML document with my own element which I create on the fly. The text may be a huge bulk of text, html, images, what-ever, and what I want is to find the first (or all) the position of a certain string, and replace it with an element that I create using $('< span>'). Using simple te...

Multiple REPLACE function in Oracle

I am using the REPLACE function in oracle to replace values in my string like; SELECT REPLACE('THE NEW VALUE IS #VAL1#','#VAL1#','55') from dual So this is OK to replace one value, but what about 20+, should I use 20+ REPLACE function or is there a more practical solution. All ideas are welcome. ...

Replace text in file with Python

I'm trying to replace some text in a file with a value. Everything works fine but when I look at the file after its completed there is a new (blank) line after each line in the file. Is there something I can do to prevent this from happening. Here is the code as I have it: import fileinput for line in fileinput.FileInput("testf...

Text replace with regex in SQL Server

Currently I have a SQL server column of type nvarchar(max) which has text that starts with <span class="escape_<<digits>>"></span> The only thing that varies in the pattern is the <<digits>> in the class name. The common part is <span class="myclass_ and the closing </span> Some sample values are <span class="myclass_12">...

Replacement of text using JavaScript

i want to replace some selected character from my text-area with some string. To do this i wrote the following JavaScript code var old_tag = "["; var tag= " <xsl:value-of select = "; var endtag= " />"; var txt=''; if(document.selection) { txt = document.selection.createRange().text document.selection.creat...

Find&Replace using Python - Binary file

Hello, I'm attempting to do a "find and replace" in a file on a Mac OS X computer. Although it appears to work correctly. It seems that the file is somehow altered. The text editor that I use (Text Wrangler) is unable to even open the file once this is completed. Here is the code as I have it: import fileinput for line in fileinp...

Regexp for selecting spaces between digits and decimal char

I want to remove spaces from strings where the space is preceeded by a digit or a "." and acceded by a digit or ".". I have strings like: "50 .10", "50 . 10", "50. 10" and I want them all to become "50.10" but with an unknown number of digits on either side. I'm trying with lookahead/lookbehind assertions like this: $row = str_replace("...

String replacement on a whole text file in Python 3.x?

How can I replace a string with another string, within a given text file. Do I just loop through readline() and run the replacement while saving out to a new file? Or is there a better way? I'm thinking that I could read the whole thing into memory, but I'm looking for a more elegant solution... Thanks in advance ...