Results 1 to 6 of 6

Thread: [RESOLVED] Like operator for c/c++ ?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,055

    Resolved [RESOLVED] Like operator for c/c++ ?

    Have a small need for a basic like operator in a c++ program.
    Something relatively simple on the scale of the vb6 or sql like operators. Don’t want the complexity of a full regex library.

    Any ideas?

    I could probably rip something from SQLite or MySQL but may not be that easy. Haven’t turned up anything good in web searches yet.

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,055

    Re: Like operator for c/c++ ?

    Some more googling turned up some potential answers.

    One guy did rip the pattern match function from SQLite:
    https://stackoverflow.com/questions/...milar-use-in-c

    And I also found a compact regex lib that supports the basics:
    https://github.com/kokke/tiny-regex-c

  3. #3
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    996

    Re: Like operator for c/c++ ?

    What functionality do you need from 'like'?

    I don't use SQL so don't know what its like does. But in past years when someone talked about 'like' they often meant something like soundex (or variations).

    So like("family", "fammilly") would be true
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,055

    Re: Like operator for c/c++ ?

    It’s like a simplified regex supporting * to match multiple characters, ? To match any single one
    And a couple more basics: https://docs.microsoft.com/en-us/off.../like-operator

    The more I think about it, For this application I probably only need the * so could cook one up pretty easily I guess with splitting the pattern string and then making sure that each case insensitive fragment exists with a start position after the last.

    I think I will just start with that micro regex library though to try it out.

    It’s going to be used to exclude file paths from reporting/auto save in a ReadDirectoryChanges file system watcher. Events can come cruising in at a rapid pace. So the smaller and faster the better.

    https://github.com/dzzie/dirwatch_cli
    Last edited by dz32; Jun 9th, 2022 at 07:12 AM.

  5. #5
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    996

    Re: Like operator for c/c++ ?

    If all you want is something simple, then have a look at as a starter:

    https://www.cs.princeton.edu/courses...beautiful.html
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,055

    Re: Like operator for c/c++ ?

    Thanks I’ll check it out

    edit: resolved the sqllite rip converted to wchar_t did the job well.
    Last edited by dz32; Jun 11th, 2022 at 11:56 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width