replace

Python: Need to replace a series of different substrings in HTML template with additional HTML or database results

Situation: I am writing a basic templating system in Python/mod_python that reads in a main HTML template and replaces instances of ":value:" throughout the document with additional HTML or db results and then returns it as a view to the user. I am not trying to replace all instances of 1 substring. Values can vary. There is a finite...

Regex : how to get words from a string (C#)

My input consists of user-posted strings. What I want to do is create a dictionary with words, and how often they've been used. This means I want to parse a string, remove all garbage, and get a list of words as output. For example, say the input is : "#@!@LOLOLOL YOU'VE BEEN *PWN3D* ! :') !!!1einszwei drei !" The output I need is the...

string replace in a large file with php

I am trying to do a string replace for entire file in PHP. My file is over 100MB so I have to go line by line and can not use file_get_contents(). Is there a good solution to this? ...

How Do I replace all Occurrences of / with _ in JavaScript?

For some reason the "".replace() method only replaces the first occurrence and not the others. Any ideas? ...

Transform title into dashed URL-friendly string

I would like to write a C# method that would transform any title into a URL friendly string, similar to what stackoverflow does: replace spaces with dashes remove parenthesis etc. I'm thinking of removing Reserved characters as per RFC 3986 standard (from Wikipedia) but I don't know if that would be enough? It would make links workab...

Regular Expression - replace word except within a URL/URI

Writing a globalization module for a web application and I need a regexp to replace all instances of a word with another word (the translation) - except - words found within a URL/URI. EDIT: I forgot to mention that I'm using Ruby, so I can't use 'Lookbehind' ...

update replace command in mysql

All, In a field named(path) in The table named is recn i have the follwoing data /home/user1/Computer-Science-10_1-10_7-17//html/Compu.html how do i replace /home/user1/Computer-Science-10_1-10_7-17//html/Compu.html with /home/user1/path/files/Computer-Science-10_1-10_7-17//html/Compu.html in mysql Also There are many rows like /h...

jquery ::: replace hyperlink text?

Just trying to replace the hyperlink text and I'm not finding a way to do this... I tried the code below, but, I get a syntax error? EDIT <script type="text/javascript"> var $j = jQuery.noConflict(); $j(function() { if($j("a").text() == "Contact") { $j("a").text() = "Connect"); } }); </script>...

Adding backslashes without escaping [Python]

I need to escape a & character in a string. The problem is whenever I string = string.replace ('&', '\&') the result is '\\&'. An extra backslash is added to escape the original backslash. How do I remove this extra backslash? ...

Aggregate regex replace

So this is purely a question of curiosity... Say I have a set of tags: <tag> <sub>A</sub> <sub>B</sub> <sub>C</sub> </tag> <tag> <sub>1</sub> <sub>2</sub> <sub>3</sub> </tag> Is it possible to, in a single Regex.Replace command, aggregate the contents of all <sub> tags within a <tag> into one <sub>. Like so: <tag><sub>A...

Parse whole html document and replace specific parts of it automatically PHP

Greetings, Iv'e made a rapid search in the previous questions but did not find an adequate answer for my question. I have create a function that finds words in an array library and replace these by links to the description of the word. Example : $words = array("ANTIM","APDIV","APVEG","ARCHE","ARFEU","ARMUR", "ARSUP","ARTHE","ARTIL","...

How can I escaped regular expression metacharacters from an interpolated variable in Perl?

I need to create a "obscuring" function which replaces clear-text password in line, before writing it to log. It looks like this: function pass_obscure { my $logline = shift; my $pass = "wer32pass$"; # this password is an example, the real one is received as parameter, or already stored as global value $logline =~ ...

Replacing all GUIDs in a file with new GUIDs from the command line

I have a file containing a large number of occurrences of the string Guid="GUID HERE" (where GUID HERE is a unique GUID at each occurrence) and I want to replace every existing GUID with a new unique GUID. This is on a Windows development machine, so I can generate unique GUIDs with uuidgen.exe (which produces a GUID on stdout every tim...

Java : replace regexp with processed match

Let's say I have the following string : String in = "A xx1 B xx2 C xx3 D"; I want the result : String out = "A 1 B 4 C 9 D"; I would like to do it a way resembling the most : String out = in.replaceAll(in, "xx\\d", new StringProcessor(){ public String process(String match){ int num = Integer.parseInt(matc...

Is there an Icacls funtion similar to /replace in subinacl?

My company has been utilizing the subinacl tool to fix SIDs that change unexpectedly. We are now switching over to Windows 7 and the subinacl tool is no longer utilized. I am trying to find the code equivalents of the subinacl funtions for Icacls and so far the only one I have been unable to find has been /replace. The /substitute functi...

SQL: replace with few records (mysql)

There's an index table. (Links tags with ids). REPLACE INTO com_index (word, ids) VALUES ('word1', concat(ids, ' 2')), ('word2', concat(ids, ' 2')) word is a primary key. I try to look through rows, add ' 2' to ids in those of them, which exist; and create a new row with ' 2' if it doesn't. So, I need to look if there's any row wit...

Jquery Getting a relative path for an image swap (not the rollover image)

I am trying to replace an image when a link in another part of the page is rolled over. I have a hard coded version working, but I would like to get this so that when I upload to a server I do not need to go in and change the path part. $(document).ready(function() { $('.laundryLinks li a').hover(function() { $('.homeLaundryPict').attr...

Perl - using a regular expression to search for all instances yet replace only the first.

I would like to search for all instances and replace all separately, even if identical. #!/usr/bin/perl use strict; use warnings; my %dataThing; my $x=0; my $data = "1 - 2 - 2 - 4 - 7 - 343 - 3 - 1"; if( my @dataArray = ( $data =~ m/([0-9]+)/gis )){ foreach( @dataArray ) { my $replace = "[thing-" . $x . "]"; # someh...

Javascript replace() doesn't work in VS - unknown character

I'm trying to use the javascript replace function to replace curly quote with straight quotes: var EditedContent = content.replace(/“/g, '"'); This works great in a little proof of concept html file I've whipped up, but when it's in a visual studio project, it replaces the curly quote with a symbol that suggests 'unknown character': ...

javascript: replace linebreak

I'm having a string which contains a chr(13) as linebreak. How can i replace it with eg. <br>? I tried mystring.replace("\n","<br>"); but it didn't work Thanks in advance. ...