replace

Modify a single XML attribute in C#

I've got it writing the XML doc fine, and it will look something like this <Team> <Character Name="Bob" Class="Mage"/> <Character Name="Mike" Class="Knight"/> </Team> I'm trying to find a way to access "Class" attribute of a single character and modify it. So far, i've got it to the point where I can pinpoint a specific character,...

Regex replaces everything that matches any character

a[b].innerHTML=a[b].innerHTML.replace(RegExp('['+bbc[c][0]+']','ig'),bbc[c][1]) This is basically what I'm working with. It's wrapped in two loops so that should explain why it looks like what it does. Basically I want to replace something that matches '['+variable from an array+']'. I'm making a BBCode script for a free forum and no d...

Removing HTML tags from a unicode string in Python

Hey all, I have a strong that I scraped from an XML file and It contains some HTML formatting tags (<b>, <i>, etc) Is there a quick and easy way to remove all of these tags from the text? I tried str = str.replace("<b>","") and applied it several times to other tags, but that doesn't work ...

Javascript replace method, replace with "$1"

I'm reading Sitepoints 2007 book "Simply Javascript" and I encountered some code I just can't understand. It's the following code: Core.removeClass = function(target, theClass) { var pattern = new RegExp("(^| )" + theClass + "( |$)"); target.className = target.className.replace(pattern, "$1"); target.className = target.clas...

JavaScript replace

I'm doing something like: <p>SQL</p> <p>sql</p> <p>sQl</p> <p>SqL</p> <script type="text/javascript"> var ps = document.getElementsByTagName('p'); for(var i = 0; i < ps.length; i++) { var p = ps[i]; p.childNodes[0].nodeValue.replace(/sql/gi, 'VB.NET'); p = null; } </script> But it's not replacing the text. What's wrong? Thank you....

jQuery replace doesn't work

Script replaces rel attributes to class. Full code - http://jsbin.com/efozi3/8/ It doesn't work for links, where used more than 2 values in rel. An example - the first item: <a class="s1" rel="t1 t2 t3" href="#">One</a> First three <li> should become blue, but now only the first one does. <li class="t1"> <strong>1</strong> ...

How do I filter this line "XX<i>\r</i><i>\n</i>" to XX?

Question is in the title. I tried strip_tags, but that shows up blank and I tried using preg_replace, but I don't quite understand the syntax apparently.. Tried this $test = "Home<i>\r</i><i>\n</i>"; $patterns = array(); $patterns[0] = '<i>'; $test = preg_replace($patterns, '', $test); but echo $test is still...

js replace global doesn't like +?

So I've been playing around with the replace function (method?) in js. $get('msgBar').replace(/+/g,' '); Let's say the content of $get('msgBar') is "Welcome+back+now". replace('+',' ') would only replace the first +, and not the second. replace(/+/g,' ') crashes replace(/"+"/g,' ') and replace(/\+/g,' ') are both the same as the fi...

HtmlAgilityPack create node from text

Let's assume I have this <div> <p>Bla bla bla specialword bla bla bla</p> <p>Bla bla bla bla bla specialword</p> </div> I want to replace the word specialword from my html with a node, for example <b>specialword</b>. This is easy using string replacement, but I want to use the Html Agility Pack features. Thanks. ...

Ant mapper: Changing file name using a property

I have a ant property app.prod= production During the an build, I want to replace all files in a particular directory with production in its name to same nma e without 'production' in it. Example File names are abcproduction.xls cdeproduction.xls I want to remove change the file names to abc.xls cde.xls <regexpmapper from="(.*)$...

Updating serialised array in mysql (without unserialising?)

Everything I've read says that storing serialised arrays in Mysql is a bad idea - I know that already ;) Unfortunately I'm working with an open source script that uses this method, and changing the structure isn't an option in this scenario. Is it possible to update this URL without first unserialising? I originally tried using replace...

Groovy xml parse then rebuild

With more than a little help from daviderossi.blogspot.com I have managed to get some code working to replace an xml value with another def fm_xml = '''<?xml version="1.0" encoding="UTF-8"?> <MAlong> <Enquiry.ID>SC11147</Enquiry.ID> <student.name_middle></student.name_middle> <student.name_known></student.name_known> <student.name_previ...

How to automatically replace `url` in browser address bar with JavaScript: from /en/services/ to /en/#services ?

How to automatically replace url in browser address bar with JavaScript from   company.com/en/services/ to       company.com/en/#services ? Example: when I type in browser address bar url company.com/en/services/ and click 'Go', it will be automatically seen company.com/en/#services Is there any way to replace real url /services/ with h...

How to replace strings in C, just using stdio.h???

It's a part of my final project; I don't understand C well. I have just this, and I don't know anything more. Please don't delete my question. I was looking for the answer a long time. I guess I'm not the only student with this problem. And why is there no option to send a private message or see a user's e-mail? wow, guys...actually i ...

Remove all multiple spaces in Javascript and replace with single space

How can I automatically replace all multiple spaces with one single space in Javascript? I've tried with just chaining some s.replace but this doesn't seem optimal. I'm using jQuery as well in case it's a builtin functionality. ...

multiple replaces with javascript

In PHP, you do this to replace more then one value at a time. <?php $string = "jak har en mamma"; $newstring = str_replace(array('jak', 'mamma'), array('du', 'pappa'), $string); echo $newstring; ?> How do you do this in javascript? ...

Replacing image extensions in jQuery, go from .png to .gif on the fly

So, I'm using CSS3 in order to create sidebar boxes in my site design, this works nice and dandy. Using http://css3pie.com in order to create the effect in IE. Again, nice and dandy. Now, comes my issue - For each relatively positioned module, there is an absolutely positioned icon within it, that is set to being top: -20px in order t...

Replace text in PHP

We have a variable with hmtl code inside. <?php echo $list; ?> This will give something like: <li><a href='http://site.com/2010/' title='2010'>2010</a></li> <li><a href='http://site.com/2009/' title='2009'>2009</a></li> <li><a href='http://site.com/2008/' title='2008'>2008</a></li> Want to add class for each <li>, it can be taken f...

Replacement of random string/char array characters using match ups.

while (1) { char j; if (x[j] == y[j]) Here I am trying to start a loop where I want to able to match any of the characters from char array 'x' with char array 'y'. If the characters do match from x to y then I want to keep them as they are and if they don't I want to be able to replace them with a star '*'. (e.i. x = [a,p,f] an...

replace string with javascript using regex

Hi I have text inside "textarea" and I was trying to remove the text between: <textarea></textarea> using replace function with some regex. here is what I did so far: x = '<TEXTAREA style="DISPLAY: none" id=test name=test>teeeeessst!@#$%&*(LKJHGFDMNBVCX</TEXTAREA>'; x.replace('/<TEXTAREA style="DISPLAY: none" id=test name=test>.*</TEXT...