String Matching Problem (NUXI problem) ?

Discussion in 'C Programming' started by timmu, May 18, 2006.

  1. timmu

    timmu Guest

    I have a binary file (actually it's in memory)
    which saved character as a reverse-byte order which means

    ABCDEFGX stores as BADCFEXG

    is there some function like strstr() in c standard library to match
    substring "BCDE" (but in reverse-order for) how could I do it?

    while I try to solve my problem myself,I found
    ABCDEFGX may stores AYCBEDGFRX in the binary file, Y,R are some
    characters I don't care.

    this maybe called NUXI problem or something like that I try to google
    it out but can't find anything useful.
    timmu, May 18, 2006
    #1
    1. Advertising

  2. timmu

    Bill Pursell Guest

    timmu wrote:
    > I have a binary file (actually it's in memory)
    > which saved character as a reverse-byte order which means
    >
    > ABCDEFGX stores as BADCFEXG
    >
    > is there some function like strstr() in c standard library to match
    > substring "BCDE" (but in reverse-order for) how could I do it?
    >


    I'm not certain I understand your problem...if you
    are trying to match "this string.", why don't
    you just search for "htsis rtni.g"?
    Bill Pursell, May 18, 2006
    #2
    1. Advertising

  3. timmu

    timmu Guest

    well, my problem is
    "this string" may be presented like
    "htsis rtni.g" or "tXih srtnig" where X character is something I don't
    need.

    actually I need to parse some strings like "arg1=On,arg2=False"
    which "arg2" may present like "ra2gF=" or "a,gr=2"
    timmu, May 18, 2006
    #3
  4. timmu

    Jordan Abel Guest

    On 2006-05-18, Bill Pursell <> wrote:
    >
    > timmu wrote:
    >> I have a binary file (actually it's in memory)
    >> which saved character as a reverse-byte order which means
    >>
    >> ABCDEFGX stores as BADCFEXG
    >>
    >> is there some function like strstr() in c standard library to match
    >> substring "BCDE" (but in reverse-order for) how could I do it?
    >>

    >
    > I'm not certain I understand your problem...if you
    > are trying to match "this string.", why don't
    > you just search for "htsis rtni.g"?


    Because he could be looking for "t?ih stsirgn?." instead?
    Jordan Abel, May 18, 2006
    #4
  5. On Thu, 18 May 2006 09:38:00 -0700, timmu wrote:

    > I have a binary file (actually it's in memory)
    > which saved character as a reverse-byte order which means
    >
    > ABCDEFGX stores as BADCFEXG
    >
    > is there some function like strstr() in c standard library to match
    > substring "BCDE" (but in reverse-order for) how could I do it?
    >
    > while I try to solve my problem myself,I found
    > ABCDEFGX may stores AYCBEDGFRX in the binary file, Y,R are some
    > characters I don't care.
    >
    > this maybe called NUXI problem or something like that I try to google
    > it out but can't find anything useful.


    The usual rule round here is to post actual (minimal) code the exhibits the
    problem.

    For example, cut down the program that "may store" ABCDEFGX as AYCBEDGRX,
    post it here and you will be flooded with helpful replies.

    --
    Ben.
    Ben Bacarisse, May 18, 2006
    #5
  6. timmu

    Ed Prochak Guest

    timmu wrote:
    > I have a binary file (actually it's in memory)
    > which saved character as a reverse-byte order which means
    >
    > ABCDEFGX stores as BADCFEXG


    Actually it stored binary WORD values in little endian byte order. (at
    least I think that's it. I sometimes confuse little endian and big
    endian.)
    >
    > is there some function like strstr() in c standard library to match
    > substring "BCDE" (but in reverse-order for) how could I do it?


    Why not just write a simple filter program or routine to reverse the
    bytes?

    >
    > while I try to solve my problem myself,I found
    > ABCDEFGX may stores AYCBEDGFRX in the binary file, Y,R are some
    > characters I don't care.
    >
    > this maybe called NUXI problem or something like that I try to google
    > it out but can't find anything useful.


    try looking for little endian and big endian

    ed
    Ed Prochak, May 19, 2006
    #6
  7. timmu

    Malcolm Guest

    "timmu" <> wrote in message
    news:...
    >I have a binary file (actually it's in memory)
    > which saved character as a reverse-byte order which means
    >
    > ABCDEFGX stores as BADCFEXG
    >
    > is there some function like strstr() in c standard library to match
    > substring "BCDE" (but in reverse-order for) how could I do it?
    >
    > while I try to solve my problem myself,I found
    > ABCDEFGX may stores AYCBEDGFRX in the binary file, Y,R are some
    > characters I don't care.
    >
    > this maybe called NUXI problem or something like that I try to google
    > it out but can't find anything useful.
    >

    The best solution is to write a function

    unscramble(char *littleendian)
    {
    }
    This is trivial to implement. The only snag is that you need to know the
    phase - whether you start in the middle of 16-bit block or not.
    --
    www.personal.leeds.ac.uk/~bgy1mm
    Malcolm, May 20, 2006
    #7
    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. Seth
    Replies:
    1
    Views:
    1,067
    Ray Andraka
    Aug 1, 2003
  2. =?ISO-8859-1?Q?Martin_J=F8rgensen?=
    Replies:
    5
    Views:
    1,281
    =?ISO-8859-1?Q?Martin_J=F8rgensen?=
    May 6, 2006
  3. Matt Brooks

    String Matching Problem

    Matt Brooks, Oct 28, 2009, in forum: Ruby
    Replies:
    11
    Views:
    150
    Matt Brooks
    Oct 29, 2009
  4. Marc Bissonnette

    Pattern matching : not matching problem

    Marc Bissonnette, Jan 8, 2004, in forum: Perl Misc
    Replies:
    9
    Views:
    221
    Marc Bissonnette
    Jan 13, 2004
  5. Bobby Chamness
    Replies:
    2
    Views:
    215
    Xicheng Jia
    May 3, 2007
Loading...

Share This Page