Diff files with regex comparing

Discussion in 'Perl Misc' started by Michael Yang, May 13, 2007.

  1. Michael Yang

    Michael Yang Guest

    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!!
     
    Michael Yang, May 13, 2007
    #1
    1. Advertising

  2. 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
     
    Josef Moellers, May 14, 2007
    #2
    1. Advertising

  3. 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
     
    Josef Moellers, May 14, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cyril Vi?ville

    diff Process under diff users

    Cyril Vi?ville, Jun 29, 2004, in forum: Perl
    Replies:
    1
    Views:
    518
    Joe Smith
    Jun 29, 2004
  2. Berrucho
    Replies:
    2
    Views:
    655
    Infant Newbie
    Dec 5, 2003
  3. A Traveler

    Diff CSS styles for diff INPUT TYPE='s?

    A Traveler, Aug 31, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    4,941
    Steve Fulton
    Aug 31, 2004
  4. Austin Ziegler

    [ANN] Diff::LCS 1.1.0, Diff::LCS 1.0.4

    Austin Ziegler, Aug 8, 2004, in forum: Ruby
    Replies:
    3
    Views:
    201
    Austin Ziegler
    Aug 9, 2004
  5. Michael Yang

    Diff Files contaning regex pattern string

    Michael Yang, May 13, 2007, in forum: Perl Misc
    Replies:
    0
    Views:
    104
    Michael Yang
    May 13, 2007
Loading...

Share This Page