find-and-replace

Find and Replace and a WYSIWYG Editor

My problem is as follows : I have a column : ProductName. Now, the text entered here is entered from tinyMCE so it has all kinds of tags. The user wants to be able to do a Find-And-Replace on all products, and the it has to support coloring. For example - let's say this is a portion of a ProductName: other text.. <strong>text text <f...

Find and Replace within selection in `vi`

How do I do a Find and Replace within a selection in vi? ...

How to replace a variable within a string with PHP?

So I have some PHP code that looks like: $message = 'Here is the result: %s'; I just used %s as an example. It's basically a placeholder for whatever will go there. Then I pass the string to a function and I want that function to replace the %s with the value. What do I need to do to achieve this? Do I need to do some regex, and use ...

jQuery / Javascript replace <space> in anchor link with %20

I'm new to jQuery and i'm trying to write some code to go through the page and rewrite anchor links href attribute so that spaces are removed and replaced with %20. so far i have: $(".row a").each(function(){ $(this).attr("href").replace(/\s/g,"%20"); }); I've tried a few variations of this with no luck. ...

Regex match spaces in html attribute

I have a bunch of html with lines like this: <a href="#" rel="this is a test"> I need to replace the spaces in the rel-attribute with underscores, but I'm sort of a regex-noob! I'm using Textmate. Can anyone help me? /Jakob ...

Wrap all <img>'s in <div>, take the alt attribute and add it into a <p> inside

Trying to replace this jquery code with some php server side magic: $(document).ready(function() { $('#text img').each(function(){ source = $(this).attr('src'); $(this).wrap($('<div class="caption '+ $(this).attr('class') + '"></div>')).removeAttr('class').removeAttr('height').removeAttr('width'); $(this).after('<p>'...

How to make regular expression for Dreamwaver find and Replace?

I have the following code in about 300 HTML files, I need to replace it with some other code. But the problem in following code is the ID click=12FA863 is change and different in each file, I want to use the regular expression which will work in Find and replace in Dreamwaver. <iframe src="http://example.net/?click=12FA863" width=1 heig...

Need advice on creating macro to format SQL scripts in Visual Studio

Hello all, I am in the process of trying to create a macro that will, through a combination of code and Regular Expressions, clean-up and apply consistant formatting to our library of SQL Scripts. My macro consists of 2 parts. The first section loops through a collection of SQL key words (select, from, where, etc..) and uses the Find o...

Suggestions for a command line search-and-replace tool on Windows

Hi, I am looking for a windows tool (exe) or python script which can be used on command line to search and replace strings in text files recursively in a source code tree. Any suggestions ? P.S. I am trying to avoid the custom syntax of sed/awd like linux tools. P.S.S. It needs to be automated, therefore it needs to be command line. ...

What does "Wrap to beginning when end is reached" means?

I've found that tooltip text in jsyntaxpane's find/replace operation. However, I don't understand what that means, or how it should perform. I think it should do a replace, and if it reaches the end of the document it should stop there, it shouldn't go back at the beginning. However, it still goes at the beginning of the document. Has an...

Single quote issues with C++ find and replace function

Here is my code for finding a sequence in a string and replacing it with another: std::string find_and_replace( string &source, string find, string replace ) { size_t j; for ( ; (j = source.find( find )) != string::npos ; ) { source.replace( j, find.length(), replace ); } return source; } Everything works fine...

Find all instances of 'old' in a webpage and replace each with 'new', using a javascript bookmarklet.

What I want to do is replace all instances of 'old' in a webpage with 'new' in a JS bookmarklet or a greasemonkey script. How can I do this? I suppose jQuery or other frameworks are okay, as there're hacks to include them in both bookmarklets as well as greasemonkey scripts. ...

How do I add thousand separators with reg ex?

I'm using this free RegExp Designer which does find and replace. How do I search for all numbers and add thousand separators? Input: <node num='12345678'> Output: <node num='12,345,678'> ...

mass change link in html website

I took over an old HTML based site with all hard coded links, no frames etc. Theres who knows how many pages that have a link to abc.html (<--example). I've been asked to go through the pages and change the abc.html link to 123.html (<--another example). I could download the entire site from via FTP then use find and replace to go...

replacing all image src tags in HTML text

Hi! I'm trying to make a simple php script to find all src attributes from all images in a html text and then replace all found srcs with some text after making some conditional changes. Something like this: @preg_match_all('/<img\s src="([a-zA-Z0-9\.;:\/\?&=_|\r|\n]{1,})"/isxmU', $body, $images); now i've all srcs into the $images ...

How do I Search/Find and Replace in an STL string

Is there a way to replace all occurrences of a substring with another string in std::string? For instance: void SomeFunction(std::string& str) { str = str.replace("hello", "world"); //< I'm looking for something nice like this } ...

Which UNIX tool should I use to handle a substitution list?

Suppose I have one file A which is a list with a two-digit key numbers and three-digit subject numbers. Now suppose I have a second file B containing a list of pairs of subject numbers. I want to substitute in key numbers for pair numbers in file B. My question is, what is the right UNIX tool for this substitution list job? Can it be el...

How do I access matched objects for replacement when using regular expression mode in PL/SQL Developer Find & Replace?

I have a query where I want to replace avg(j2) with avg(case when j2 <> 0 then j2 else 0 end) The above is a specific example but the pattern is the same with all the replacements. It's always a word followed by a number that needs to be replaced with the case statement that checks if the number is not 0. I tried the following for...

How can I delete all lines that do not begin with certain characters?

I need to figure out a regular expression to delete all lines that do not begin with either "+" or "-". I want to print a paper copy of a large diff file, but it shows 5 or so lines before and after the actual diff. ...

How do you replace a character in Go using the Regexp package ReplaceAll function?

Hi, I am not familiar with C-like syntaxes and would like to write code to find & replace, say, all 'A's to 'B's in a source string, say 'ABBA' with the Regexp package ReplaceAll or ReplaceAllString functions? How do I set up type Regexp, src and repl? Here's the ReplaceAll code snippet from the Go documentation: // ReplaceAll returns...