Given the following text in Vim:
[2] [3] [4]
I want to perform a search and replace and produce the following:
[1] [2] [3]
I know how to extract out the numbers using back-reference via search and replace:
:%s/\[\(\d\)\]/[\1]/g
But now the question is how do you go about decrementing the value of \1.
Any ideas?
...
I need to replace text into link in
Link must be look like " href="/search?q=$oldtext" title="$oldtext" ".
$oldtext is text to replace.
I'm tried to use loop to find text with regexp "/^\x23\w/",and replacing with variable that contain generated link.
And it result to nothing.
I've edit regexp to "/\x23/" and get replacing for "#" (\x...
I have a Perl script called replaceUp:
#!/usr/bin/perl
search=$1
replace=$2
find . -type f -exec perl -p -i -e "s/$search/$replace/g" {} \;
The script does not get loaded. This suggests me that my script is wrong.
How can you make a shell script using Perl?
...
Hi:
I have the following script that takes in an input file, output file and
replaces the string in the input file with some other string and writes out
the output file.
I want to change the script to traverse through a directory of files
i.e. instead of prompting for input and output files, the script should take
as argument a directo...
Hi, I am trying to construct a regular expression to search and replace a file. The following is the script.
#!use/bin/perl
use strict;
use warnings;
my $line = $ARGV[0];
my $find = "[^a-zA-Z0-9]+seqfile[^a-zA-Z0-9]+=[^a-zA-Z0-9]+[a-z]+..";
my $replace = "done"; open (FILE, ">>/home/user/Desktop/test") || die "cant open file \n"; ...
I am trying to read a directory which consists of hundreds of files. For every file in the directory, I am supposed to access(edit) an another file and replace a particular string 'information=filename' in that file by file names 'information=' present in '/home/test/test_these_files' directory. This is followed by executing the file '/h...
I got a markup with the following structure :
<body>
<h1>Title</h1>
<p>bla</p>
<div>
... <!-- a thousand tags -->
</div>
<div id="do-not-modify-me">
<!-- a hundred tags -->
</div>
</body>
I wish to do a little search an replace in the body, but this must not change #do-not-modify-me because it has JS events attach...
I am coding a little bookmarket to convert all the devises in the current page to another. I heavily relies on regexp, and I use Jquery to easy the work.
For now, I do that like a big fat pig, replacing all the body :
$("body").children().each(function(){
var $this = $(this);
var h = $.html().replace(/eyes_hurting_regexp/g, "my...
I need to substitute a list of words with with an equally long list of words.
So for example you have:
"a","b","c","d","e","f"
And you want to replace each word with the uppercase version of each word:
"A","B","C","D","E","F"
I know how to find each string using the regex:
(a\|b\|c\|d\|e\|f)
I know you could do a global substitution ...
I want to perform a batch replace operation on a project by following some rules. For e.g. I am taking notes in the code like this:
On every code piece, which is commented like this, I want to perform a replace operation, which will replace the input code piece with the output code piece in the following examples:
Input 1:
//+
a++;
//...
Hello,
i need to let sed replace some url in alot of file each file has the following
http://www.expample.com/file.php?id=xxxxxxx
where xxxxx consist of random numbers , random depth in each file like
file 1
_h**p://www.expample.com/file.php?id=xx
file 2
_h**p://www.expample.com/file.php?id=xxxxxxxx
etc
thanks in advance
...
I have the following string:
This *is* a *test*!
I want to bold the words surrounded by the * characters (so "is" and "test" in the example).
I have the following JavaScript code:
var data = "This *is* a *test*!";
return data.replace(/\*(.*)\*/g, <b>$1</b>);
When the string is returned, I get the following:
This <b>is* a *test</b...
Say I have the following style of lines in a text file:
"12" "34" "some text "
"56" "78" "some more text"
.
.
.
etc.
I want to be able to remove the quotes surrounding the first two columns. What is the best way to do this with VIM (I'm currently using gVim)?
I figured out how to at least delete the beginning quote of each line b...
First off I don't know much about regex and need to buy a book because it's has proven to me to be difficult to pickup.
Ultimately I want to take a dom element, and replace text within straight brackets "[" and "]" and insert a link around the text, and there may be multiple bracket sets in the string.
function changeTip() {
...
I tried removing all newlines (\n) from the values of a hash:
my %var_h = ( "ID" => " This is Test
This is new line TEST
newline Test end ");
How can I remove all the new lines from the values of %var_h?
I tried s/\\n//g but I could not get it to work.
...
My SQL knowledge is very limited, specially about SQLite, although I believe this is will be some sort of generic query... Or maybe not because of the search and replace...
I have this music database in SQLite that has various fields of course but the important ones here the "media_item_id" and "content_url".
Here's an example of a "co...
Okay, here's what I'm trying to do: I'm trying to use PHP to develop what's essentially a tiny subset of a markdown implementation, not worth using a full markdown class.
I need essentially do a str_replace, but alternate the replace string for every occurrence of the needle, so as to handle the opening and closing HTML tags.
For examp...
Ok, I am trying to filter a list/dictionary passed to me and "clean" it up a bit, as there are certain values in it that I need to get rid of.
So, if it's looking like this:
"records": [{"key1": "AAA", "key2": "BBB", "key3": "CCC", "key4": "AAA"...}]
How would I quickly and easily run through it all and replace all values of "AAA" wi...
What's the syntax to perform a search/replace on Eclipse and use "match groups" ( is that it's name? "
On vi I:
%s/log(.*)/log \1 debug/g
And lines like:
log "Message"
are replaced with
log "Message" debug
What's the correct syntax for eclipse in the search/replace dialog box ( beside checking up "Regular expressions" )
Than...
I'm working on some code that is normalizing a lot of data. At the end of processing, a number of key="value" pairs is written out to a file.
The "value" part could be anything, so at the point of output the values must have any embedded quotes escaped as \".
Right now, I'm using the following:
outstream << boost::regex_replace(src, ...