I want to perform the following vim substitution as a one-liner in the terminal with Perl. I would prefer to allow for any occurences of whitespace or newlines, rather than explicitly catering for them as I am below.
%s/blockDontForget">\n*\s*<p><span><a\(.*\)<\/span>/blockDontForget"><p><a\1/g
I've tried this:
perl -pi -e 's/bl...
I have a file containing a lot of SQL statements, such as:
CREATE TABLE "USER" (
"ID" INTEGER PRIMARY KEY,
"NAME" CHARACTER VARYING(50) NOT NULL,
"AGE" INTEGER NOT NULL
);
COPY "USER" (id, name, age) FROM stdin;
1 Skywalker 19
2 Kenobi 57
I want the column names in the COPY statements to be uppercased and quote...
I'd think there was a question on this already, but I can't find one. Maybe the solution is too easy... Anyway, I have a flat-file and want to let the user change the values based on a name. I've already sorted out creating new name+value-pairs using the fopen('a') mode, using jQuery to send the AJAX call with newValue and newName. But s...
How can I replace a string with another string, within a given text file. Do I just loop through readline() and run the replacement while saving out to a new file? Or is there a better way?
I'm thinking that I could read the whole thing into memory, but I'm looking for a more elegant solution...
Thanks in advance
...
I'm implementing a c# program that should automatize a Mono-alphabetic substitution cipher.
The functionality i'm working on at the moment is the simplest one: The user will provide a plain text and a cipher alphabet, for example:
Plain text(input): THIS IS A TEST
Cipher alphabet: A -> Y, H -> Z, I -> K, S -> L, E -> J, T -> Q
Cipher ...
I am trying to replace function calls written when methods were nonstatic to an updated version were they are.
For example: TABLE_foo(table1, ...rest is the same
with
table1.foo(...rest is the same
This is what I have come up with using my limited understanding of regex and this site.
find:
TABLE_(*)\((*),
replace:
$2.$1(
The abov...
How can I do a search for value A in column1 and add a value B in column2?
In other words for every record that column1 has the value A I want to make the value in column2 = B (Currently column2 is empty)
Would this work?
UPDATE MyTable
SET Column2 = REPLACE(Column2,NULL,'B')
WHERE Column1 = "A"
...
I have a macro that I use to replace special characters for its html entities. I would like to save it in my .vimrc.
According to this, I should use let @r=' *macro_text_goes_here* '. The problem is that my macro is a series of search and replace, something like this:
:%s:á:\á:Ige
:%s:é:\é:Ige
:%s:í:\í:Ige
So, I'...
I have a file with the following expressions:
something[0]
Where instead of 0 there could be different numbers. I want to replace all these occurances with
somethingElse0
Where the number should be the same as in the expression I replaced. How do I do that?
...
I want to write a python code that open a text file and Replace with a word that i want send to it .
May you give me an example ?
Thanks .
...
Lets say I have a bunch of areas like:
joe is punching jim
joe is kicking jim
joe is spitting on jim.
and I wanted to find every case with joe is _ jim and completely change the order around. normally I would just do a wilcard search, and search and replace "joe is [^"]* jim". but what if i wanted to KEEP whatever the wildcard was an...
How can I write a (La)TeX command that replaces all [ with { and all ] with }, assuming that every [ has a matching ], and that any braces between the [ and ] are balanced? It needs to be able to deal with nested brackets.
For example, I want to be able to write a command \mynewcommand so that \mynewcommand{{[[{1}{2}][{3}{4}]]}} is the...
I am trying to search and replace some of the text (eg 'Smith, John') in this pdf form file (header.fdf, I presumed this is treated as binary file):
'%FDF-1.2\n%\xe2\xe3\xcf\xd3\n1 0 obj\n<</FDF<</Fields[<</V(M)/T(PatientSexLabel)>><</V(24-09-1956 53)/T(PatientDateOfBirth)>><</V(Fisher)/T(PatientLastNameLabel)>><</V(CNSL)/T(PatientCons...
I would like to search all files via eclipse which contain the following 2 lines
@Length(max = L_255)
private String description;
and replace it with
@Length(max = L_255, message="{validator.description.len}")
private String description;
...
I'm working on a VS solution with 100+ projects in C#. I'm currently migrating it from VS 2008 to VS 2010. There is some work to be done because a lot of the projects use Enterprise Library 4 (which has to be upgraded to 5.0) and WCSF 2008 (which has to be upgraded to SCSF 2010). I'm going through the SCSF upgrade instructions, and one i...
I would prefer to have an empty line prior to the last return statement of any Java method. How do I find and replace such lines using Eclipse?
public int foo() {
...
...
System.out.println("end of foo");
return 1;
}
In this case , I would prefer an empty line before the return statement, do note that there could be a...
Hey everybody,
I need a function, that starts, when the DOM is loaded.
In my HTML Page are several empty Image Tags, like and I want to add an Image-Name into the src-property when everything is loaded to get something like
<img src="blank.jpg">.
Best wishes
Chris
...
I'm wondering how you can substitute the src-property (or delete the whole img-node) with JavaScript, if the browser is realizing, that the image beyond the image-src-property doesn't exist (any more).
For example:
<div id="foo">
<img src="bar">
</div>
And the img-tag is pointing to nowhere. In some browser, esp. the iE, are showi...
Hey,
I am trying to write a ruby script which will look in a directory and its subdirectories for HTML files, open those HTML files and insert the following line just above the closing head tag:
<link rel="stylesheet" href="styles.css" type="text/css" />
I am trying to do this with Ruby because its the only language I am familar with...
Hi all,
This is my 3rd post in the process of learning sed. I have a hypothetical requirement. I want to be able to replace 3rd word in each line by 'was', where words are delimited by space(s).
bash$ cat words
hi this is me here
hi this is me again
hi this is me yet again
hi this is me
Desired output:
hi this was me h...