![]() |
Diff files with regex comparing
Here I have two files to diff, I want them compared with my rules.
Let's one is base file, the other is result file: base file: Connected to the '.*' Hello everyone, I am .* Glad to see you, .* result file: Connected to the 'www.perl.com' Hello everyone, I am michael Nice to see you, all There are regex string ".*" in the base file, indicating that it could be replaced by any string. When the two lines being compared, I want it be considered equal when the ".*" matches the couter-part of the other, like the first two lines in the files shown above. So when diff these two files, only the last line is the difference data after diff. Glad to see you, .* Nice to see you, all I need to change the rules of diff program, and for that I need to implement my own diff algorithm. Is there any ways simpler to achieve this? I don't know if there are any interface providing user-defined comparison function to diff. If there is, I can implement my own comparison function telling it how to compare two lines and pass the function as the reference to the diff function. The diff function will compare and diff files using my comparison rules. Your helps are greatly appreciated!! |
Re: Diff files with regex comparing
Michael Yang wrote:
> Here I have two files to diff, I want them compared with my rules. > Let's one is base file, the other is result file: > base file: > Connected to the '.*' > Hello everyone, I am .* > Glad to see you, .* > > result file: > Connected to the 'www.perl.com' > Hello everyone, I am michael > Nice to see you, all > > There are regex string ".*" in the base file, indicating that it could > be replaced by any string. When the two lines being compared, I want > it be considered equal when the ".*" matches the couter-part of the > other, like the first two lines in the files shown above. > > So when diff these two files, only the last line is the difference > data after diff. > Glad to see you, .* > Nice to see you, all > > I need to change the rules of diff program, and for that I need to > implement my own diff algorithm. > Is there any ways simpler to achieve this? > > I don't know if there are any interface providing user-defined > comparison function to diff. > If there is, I can implement my own comparison function telling it how > to compare two lines and pass the function as the reference to the > diff function. The diff function will compare and diff files using my > comparison rules. > > Your helps are greatly appreciated!! 1. Be patient, posting the same request twice within a few minutes with different subject lines is bad. 2. This is no place to ask for ready-to-run scripts. Have a try yourself, post your code and we'll help getting bugs ironed out. -- These are my personal views and not those of Fujitsu Siemens Computers! Josef Möllers (Pinguinpfleger bei FSC) If failure had no penalty success would not be a prize (T. Pratchett) Company Details: http://www.fujitsu-siemens.com/imprint.html |
Re: Diff files with regex comparing
Michael Yang wrote:
[ Problem description deleted ] > Your helps are greatly appreciated!! 1. Be patient, posting the same request twice within a few minutes with different subject lines is bad. 2. This is no place to ask for ready-to-run scripts. Have a try yourself, post your code and we'll help getting bugs ironed out. -- These are my personal views and not those of Fujitsu Siemens Computers! Josef Möllers (Pinguinpfleger bei FSC) If failure had no penalty success would not be a prize (T. Pratchett) Company Details: http://www.fujitsu-siemens.com/imprint.html |
| All times are GMT. The time now is 11:31 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.