search-and-replace

How can I do a find & replace using PDFSharp?

Hi All, I have a PDF file with 3 static place holders that I need to replace. The place holders are using the following format: [item1ToReplace] [item2ToReplace] [item3ToRepalce] So my question is how can I read in the pdf, replace the values, and save a new pdf using PDFSharp, or a simliar opensource library? Target language is ...

java: search & replace in a Stream

How do I do on-the-fly search & replace in a Java Stream (input or output)? I don't want to load the stream into memory or to a file. I just see the bytes passing by and I need to do some replacements. The sequences being replaced are short (up to 20 bytes). ...

How to replace markup in html files stored on unix/solaris servers?

I'm looking for a way to grab a piece of markup that is in a 1000+ html files published on unix servers (running via apache) and replace the markup with either empty nodes or alternate html markup. ex: Find <div id="someComponent"> .....{a bunch of interior markup} .... </div> Replace with {empty} ex 2: Find </div></body> Replac...

MySQL - Query to move part of 1 field's contents to a new field

I have a table called cartypes which currently has 2 fields: id & type. I am adding subtype and I want to move the contents after the dash - from the field called type and put those contents into subtype. Disposing of the dash (any extra whitespace too for that matter). What's the best SQL query for this? before: id type ...

Creation of mass phrase search for website domain

I need to replace a single text phrase across my entire website domain with another one. What is the best way to do a mass search/ replace? ...

String Find/Replace Algorithm

I would like to be able to search a string for various words, when I find one, i want to split the string at that point into 3 parts (left, match, right), the matched text would be excluded, and the process would continue with the new string left+right. Now, once i have all my matches done, i need to reverse the process by reinserting t...

Good Search Tool?

Does anyone have a good search tool for OS X? I am looking for a way to search entire large directories for information in files (.g, .cpp. .txt, other txt with different extensions) and then globally replace and manage. I have a huge code base where I have to do a lot of replacements and XCode is bombing, TextMate cannot handle some ...

How to modify/update a set of html files with a standard header and footer

I have a set of html files that I want to modify by replacing the header and footer. The contents of each file is different and I would like to use a regular expression (or similar if RE can't handle multiline queries). As an example, one modification I want to make is to replace everything between <html> and </head> with a standard he...

replacing special characters in SQL 2000

Hi, how can I replace special characters in my data files (special characters such as bullet points, percent sign, hyphen etc) ? Thanks ...

Perl: replace pattern from the current position until the end of a line

In Perl, how can I replace a pattern from the current position (the position of the last replacement) until the end of a line? I have done all of these replacements in a single line: ... s/\[//; s/(\/\w\w\w\/)/ getMonth $1 /e; s/:/ /; s/\s\+\d\d\d\d\]//; #NOW: replace all blanks with a plus sign from this position until the end of this...

How can I search and replace XML based on values in a Perl hash?

I have an XML file in a string variable ($data), and a hash containing all the tag names and their contents (%field_list). The tag names are to be checked so that if they are enumerated fields, their contents should be replaced with strings. Does anybody know if it is possible to do this with search and replace? I am not having much lu...

What are the things to watch out for with case insensitive regex replace?

I have written the following code to do case insensitive replace in C#: Regex.Replace(textBoxText, Regex.Escape(findText), replaceText, RegexOptions.IgnoreCase); Just wanted to check, whether this is the right approach, or is there a better approach and whether I'm overlooking something that I should better be aware of....

How to do conditional character replacement within a string

I have a unicode string in Python and basically need to go through, character by character and replace certain ones based on a list of rules. One such rule is that a is changed to ö if a is after n. Also, if there are two vowel characters in a row, they get replaced by one vowel character and :. So if I have the string "natarook", what i...

Find two of the same character in a string with regular expressions

This is in reference to a question I asked before here I received a solution to the problem in that question but ended up needing to go with regex for this particular part. I need a regular expression to search and replace a string for instances of two vowels in a row that are the same, so the "oo" in "took", or the "ee" in "bees" and ...

How can I replace every instance of a pattern in ruby?

string.sub looks like it only replaces the first instance. Is there an option for that or another method that can replace all patterns? Can you do it inside a regex like perl? (I think something like r/blah/blah/) ... and +1 to anyone who can tell me WHY ON EARTH does string.sub replace just the FIRST match? ...

Dynamically replace html tags

I'm trying to replace some html tags which are being generated by ajax script. Ajax script generates the following ul list: <ul> <li class="odd">some text</li> <li class="even">some text</li> <li class="odd"><hr /></li> <li class="even">some text</li> </ul> I need to replace <li class="odd"><hr /></li> with </ul><hr /><ul>. I ...

search and replace in entire project on linux/osx

How would I replace one pattern with another for every file with extension .cc and .h recursively? Not sure if I need to prevent it from going into .svn directories. first attempt #!/bin/bash for file in `find . -name '*.cc' -or -name '*.h'`; do \ sed -e s/$1/$2/g -i temp $file done ...

emacs: replace string using regexp

hi, suppose i have the following in a text file (or dired buffer) open in emacs: file_01.txt file_02.txt ... file_99.txt I want to query-replace or replace the files to 01_file.txt, etc. I want to use query-replace-regexp or replace-regexp, but don't know what to put in. The search part i put in "file_..", but the ".." are read as pe...

Matching a specific tag with a specific attribute without being greedy in vs-2005

I have a bunch of files (in the hundreds) that have img tags like the following: <img randomAttr1="randomVal" randomAttr2="valueRand" border="0" randomAttr3="someRandValue"> I'm trying to do a search and replace operation in Visual Studio 2005 that will identify a tag as an <img>, but only match the border="0" potion of the stri...

Moving a value from one field to another in an SQL file

In my database I have a column named 'description' in this field There is an age at the beginning of the description ex: "Age 4+ This is a description for this row in the table". I created a column called 'age' and I have been trying to figure out a way to move the age from the description in one row to its corresponding age column. Ho...