-
Jun 8th, 2022, 07:56 PM
#1
[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.
-
Jun 9th, 2022, 03:13 AM
#2
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
-
Jun 9th, 2022, 03:20 AM
#3
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)
-
Jun 9th, 2022, 07:04 AM
#4
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.
-
Jun 9th, 2022, 07:25 AM
#5
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)
-
Jun 9th, 2022, 08:19 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|