replace

Running vim command over multiple buffers/tabs

I have a command to tidy up excessive whitespace in my code in vim: " to tidy excess whitespace map <leader>1 :execute ':%s#\s\+$##g'<CR> My question is, if I have 10 tabs or buffers open, how can I apply this command to all of them, rather than just going to each one and applying the command. Thanks, Stephen ...

replace rebuilded module JAR in the EAR (Maven2 project)

Hello. During the development time I'm iteratively rebuilding some modules of my project. Rebuilding resulting ear-project gets a huge amount of time. If there is a way allowing to rebuild only jar file of changed module and then replace this jar in resulting EAR then it could reduce build time and accelerate development process. So qu...

Regex question, how to update this C# RegexMatches routine to update/replace the items found?

Hi, Can I ask for a pointer re C# and Regex. I've got the routine that works ok below that finds links within CSS. If I wanted to rewrite the links I find as I go through, and then have a copy of a string at the end of this that represents the initial CSS text but with the rewritten links in place how would I do this? var resultL...

Python MySQLdb: Update if exists, else insert

I am looking for a simple way to query an update or insert based on if the row exists in the first place. I am trying to use Python's MySQLdb right now. This is how I execute my query: self.cursor.execute("""UPDATE `inventory` SET `quantity` = `quantity`+{1} WHERE `item_number` = {0} ...

Python regular expression matching a multiline block of text but not replacing it

Ok so i have this piece of code: def findNReplaceRegExp(file_name, regexp, replaceString, verbose=True, confirmationNeeded=True): '''Replaces the oldString with the replaceString in the file given,\ returns the number of replaces ''' # initialize local variables cregexp = re.compile(regexp, re.MULTILINE | re.DOTALL) somet...

C# text.Replace preserve case

I am working on a wiki bot for my communities wiki that uses the DotNetWikiBot Framework; it is to find a word that is commonly a typo (such as "abilty") and replaces them with the correction (such as "ability"). This works as is is coded: p.text = p.text.Replace(@"\b" + typoArray[x, 0] + @"\b", typoArray[x, 1]); However this will re...

Linux - Replacing spaces in the file names

I have a number of files in a folder, i want to replace every space character in all file names with under scores. How can I achieve this? ...

MySQL query to replace spaces in a column with underscores

I have a MySQL database table 'photos' with a column 'filename'. I need to replace the spaces in the filename column values with underscores. Is it possible with a single/multiple query? If so how? ...

Replace strings in LaTeX

I want LaTeX to automatically replace strings like " a ", " s ", " z " with " a~", " s~", " z~", because they can't be at line end. Any suggestions? ...

How to wrap a group of words with tags, JavaScript Replace Regular Expressions

I am trying to wrap some words with HTML tags, for that I am using regular expressions. I am almost there: This is my regexp /((apple|banana|cherry|orange)\b\s?)+/gi and this is my replacement: <em>$&</em> which works perfectly for my example text: Apple Banana apple cherry, Cherry orange and Oranges Apple, Banana the result be...

SQL Server: How do you remove punctuation from a field?

Hey everyone, Any one know a good way to remove punctuation from a field in SQL Server? I'm thinking UPDATE tblMyTable SET FieldName = REPLACE(REPLACE(REPLACE(FieldName,',',''),'.',''),'''' ,'') but it seems a bit tedious when I intend on removing a large number of different characters for example: !@#$%^&*()<>:" Thanks in advance ...

Find and replace multiple strings in file then output to new filename python

I am looking to create a python script that will read one source file then produce another file with a string for the name. for example macaddress.cnf.xml contains the source file I need to change '6000' to '6001' in multiple places of macaddress.cnf.xml, then I want to output to newmacaddress.cnf.xl. This is what I have #! /usr/...

Text replacing with JS

I need to replace text entered in textarea with other characters, that I will call. For example, I need to replace the text, that I will enter to the textarea by clicking some button calls "change text" using JavaScript and it will change, for example, character "a" to "1", "b" to "2", "c" to "3" etc. ...

problems with excel's application.evaluate command in vba

Hi guys, I have a problem with some excel code that I am having trouble getting my head around. Okay so I am using the application.evaluate command in excel vba, office 2007. If i have Evaluate("SIN(45)") it returns a nice predicted number. However if I do Evaluate("eq") the code crashes. eq is an equation i am reading in from excel....

Replacing a Regex Match Collection in C#

I need to find in a text everything that starts with [ and ends with ] and replace it with the value that a function returns. So, here is an example of what I'm doing: public string ProcessTemplate(string input) { return Regex.Replace(input, @"\[(.*?)\]", new MatchEvaluator(delegate(Match match) { ...

Replace Multiple lines in Jython

Hi Everyone , I have written a small program to replace a set of characters , but i also want two or more replace command in a single program . Apart from it i also want to add an bracket after random set of characters. This is my Program file_read=open('<%=odiRef.getOption("READ")%>/EXPORT.XML','r') file_write=open('<%=odiRef.ge...

MySQL: Using REPLACE as part of an IN statement

I am trying to use REPLACE to substitute spaces for commas. If I try SELECT REPLACE('1 2 3 4 5 6 7 86 9', ' ', ', '); then I get exactly what I need in a string. However, if I try this as part of an IN statement I only get returned the first match (ie, 1) Here is my entire query: SELECT aa.category_id, aa.yyyymm, ...

Re-format items inside list read from CSV file in Python

I have some lines in a CSV file like this: 1000001234,Account Name,0,0,"3,711.32",0,0,"18,629.64","22,340.96",COD,"20,000.00",Some string,Some string 2 If you notice, some numbers are enclosed in " " and has a thousand separator ",". I want to remove the thousand separator and the double quote enclosure. For the qoute enclosure, I'm t...

Java: Regex replacing

Hi, I have this String: foo bar 567 baz Now I want to add before each number the String num:. So the result has to be: foo bar num:567 baz Also this has to work: foo 73761 barbazboom!! 87 result: foo num:73761 barbazboom!! num:87 The regex to search number is this: [0-9]+ But I want to replace the matching substring with num: +...

How do I split a string that contains different signs?

I want to split a string that can look like this: word1;word2;word3,word4,word5,word6.word7. etc. The string is from an output that I get from a php page that collects data from a database so the string may look different but the first words are always separated with ; and then , and the last words with .(dot) I want to be able to fet...