search-and-replace

How to convert "string" to "*s*t*r*i*n*g*"

I need to convert a string like "string" to "*s*t*r*i*n*g*" What's the regex pattern? Language is Java. ...

Intelli-J structural search and replace problems...

Is there an easy way to capture types? I can't seem to do basic things like use variable expressions side by side, such as $mapType$$mapEnd$ to do a simple replacement. Is there any reason this might be? That is, if I have a single expression, say .*\s*.*abc, and I break it into two variables, .*\s* and .*abc, the expression does not mat...

What regex to use for replacing lines in a xml file

I have a large number of records of the following type, which I have to modify I would like to remove the created_by="29" line without leaving a space. Note: A wild card inside the created_by value would be preferable I would like to remove the entire line creation_date="..." and the /> greater should move after state="1"/> Insert a ne...

Regexp to normalise (pad with zeroes) IP addresses

Hi, I have a copy of a log file I want to make easier to view/edit. I use textpad to remove stuff I do not want and I can enter a regular expression as search term and use \1.\2.\3.\4 in the target field for captured groups. I would like to change all IP addresses which start each line from [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,...

match and replace multiple newlines with a SED or PERL one-liner

I have an input C file (myfile.c) that looks like this : void func_foo(); void func_bar(); //supercrazytag I want to use a shell command to insert new function prototypes, such that the output becomes: void func_foo(); void func_bar(); void func_new(); //supercrazytag So far I've been unsuccessful using SED or PERL. What didn't w...

Wrap Field in a Line with Variable Number of Separators

Hello all, I have a file that uses the pipe character as a separator since I assumed that most of my clients wouldn't use the pipe character in their data. Apparently I was wrong, but I compensated for this by specifying that any fields using the pipe character need to be wrapped in double quotes. Unfortunately, they haven't done this, ...

WPF: DataGrid Find and Replace

I'm using a DataGrid to display the values of specific properties of a collection of objects. I've implemented search and cell highlighting through a similar method to the one on Tomer Shamam's blog. However, I now need to implement 'Find/Replace' type functionality. I presumed I would be able to iterate through the DataGrid's cells to ...

Find similar ASCII character in Unicode

Does someone know a easy way to find characters in Unicode that are similar to ASCII characters. An example is the "CYRILLIC SMALL LETTER DZE (ѕ)". I'd like to do a search and replace for similar characters. By similar I mean human readable. You can't see a difference by looking at it. ...

How else can I replace multiple lines through the terminal in a Rails app?

Is there an alternative way to do the following one-liner replacement of text across all files in a Rails app? perl -pi -e 's/replaceme/thereplacement/g' $(find . -type f) Perl complains that there are too many files if I include the RAILS_ROOT, but it works for subdirectories. ...

Replacing \ with \\

I have a string. I want to search for a single slash and then replace "\" (single slash) with a "\" (double slash). string Method1(string s) { string upadtedString = s; if (s.Contains("\\")) { //do nothing } else if(s.Contains("\")) { string s1 = "\"; string s2 = "\\"; u...

Serializing a string with backslash

My program should process an input string. But when "\mesg" is sent in Method1, the else block is executed instead of the if block. void Method() { string str = "\\Mesg"; str = Method1(str); Console.WriteLine(str); } string Method1(string s) { string upadtedString = s; if (s.Contains(@"\\")) { ...

Regex to replace all ocurrences of a given character, ONLY after a given match.

For the sake of simplicity, let's say that we have input strings with this format: *text1*|*text2* so, I want to leave text1 alone, and remove all spaces in text2 This could be easy if we didn't have text1, a simple search and replace like this one would do: %s/\s//g but in this context I don't know what to do. I tried with somet...

What sort of Form/Window is the Excel 2010 SearchANDReplace Dialog ?

I like the Search And Replace Dialog of Excel 2010. I can enter data, see it replace in the grid behind AND THEN I can edit the data in grid without the Search/Replace Window disappearing/going into background. The SearchAndReplace Window is not a Model dialog. And it also has not settings like "stay at Top" = true because switching to ...

PHP replacing entire string if it contains integer.

My script lists out files in the directory. I am able to use preg_match and regex to find files whose filenames contain integers. However, this is what I am unable to do: I want an entire string to be omitted if it contains an integer. Despite trying several methods, I am only able to replace the integer itself and not the entire line....

How to search a line starting with a certain text using regex

/** Constant <code>IDX_USER="IDX_+ USER_ID"</code> */ I have several lines of code which was generated by javadoc and show up something like the above. I would want to find all lines starting with /** Constant IDX_ and all the way to the end of the line. How should I do this? Will be using the regex search and replace capability in Ec...

search and replace text inline in file in Python

I am trying to convert a file which contains ip address in the traditional format to a file which contains ip address in the binary format. the file contents are as follows. src-ip{ 192.168.64.54 } dst-ip{ 192.168.43.87 } The code i have is as follows. import re from decimal import * filter = open("filter.txt", "r") output = open...

How are you using the pattern matching functionality in ReSharper 5?

Resharper 5's new pattern matching seems very powerful, though it takes a bit of tinkering to work out how to use it. For those who aren't familiar with this feature, it allows you to search for specific patterns within your code. Instances of such patterns may optionally be replaced with an alternative. In IntelliJ this was called st...

Excel Macro On How To Search And Replace Cells With Multiple Values Specified in A Diffrent Sheet.

I found This. But It Dosent work. Not sure what I am doing wrong. In Sheet 1 I want to search and replace certain terms. Such as WH with White, PK with Pink, TT with Two Tone, YE with Yellow and so on. I have a list in sheet three with what to find in one column and what to replace in the same row in the next column. Now I want to us...

How do you search and replace anything beyond an equal sign

We have a property file (name, value key pairs) and would like to replace everything beyond the equal sign = with nothing. How do I do that? label.one=One label.two=Two Post replacement, I would want label.one= label.two= ...

Match all code between two HTML tags using REGEX

I'm looking for a greedy RegEx match to replace all text in a number of HTML files between </title> and </head> (I've combined loads of JavaScript files to minimize the number of http requests). I've googled it but the majority of the solutions don't seem to work for me. (Which naturally leads me to assume that i'm wrong) This is my ...