Hello devs, I would like to take up the bite sized project on adding a match command to omega script to perform a regex match. I would just like to know whether the way I am approaching this is right or wrong. The way I am planning to approach it is: 1. Add a new command in query.cc and write the implementation for this command 2. Inside implementation, we will use pcre library in a similar way to the $tranform function and take two arguments, the regex and the string to perform a match on. 3. Then using pcre library, we check for a regex match using pcre_exec( ) and if the value it returns is lesser than or equal to zero, return true or else return false. Do let me know if I'm going wrong out here. Thanks :) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.xapian.org/pipermail/xapian-devel/attachments/20160326/5f3b9010/attachment.html>
Hi Richhiey, On Sat, Mar 26, 2016 at 10:24:22AM +0530, Richhiey Thomas wrote:> I would like to take up the bite sized project on adding a match command to > omega script to perform a regex match. > I would just like to know whether the way I am approaching this is right or > wrong. > > The way I am planning to approach it is: > > 1. Add a new command in query.cc and write the implementation for this > commandThat's where a new command needs to be hooked up, but in this case I'd put the actual implementation into transform.cc alongside the implementation of $transform - then it can share $transform's regex cache (which avoids recompiling a regex if it's used multiple times, either explicitly or in something like $hitlist which gets evaluated multiple times).> 2. Inside implementation, we will use pcre library in a similar way to the > $tranform function and take two arguments, the regex and the string to > perform a match on.It would be useful to also support an optional flags argument, like $transform does. Then the user can do things like a case insensitive match.> 3. Then using pcre library, we check for a regex match using pcre_exec( ) > and if the value it returns is lesser than or equal to zero, return true or > else return false.Isn't that backwards? Cheers, Olly
On Mar 28, 2016 3:01 PM, "Olly Betts" <olly at survex.com> wrote:> That's where a new command needs to be hooked up, but in this case I'd > put the actual implementation into transform.cc alongside the > implementation of $transform - then it can share $transform's regex > cache (which avoids recompiling a regex if it's used multiple times, > either explicitly or in something like $hitlist which gets evaluated > multiple times). >Yes, that would be a much better way of hooking up the function since the regex cache doesn't need to be created again.> It would be useful to also support an optional flags argument, like > $transform does. Then the user can do things like a case insensitive > match. >Oh yes I'm sorry I forgot to mention this. We can use the options provided by the pcre library to let the user modify functionality accordingly.> Isn't that backwards? >That's the way I thought it could be done looking at the way $transform has been written. If there is any other way, do guide me through that. Can I start with trying to implement this? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.xapian.org/pipermail/xapian-devel/attachments/20160329/4522635a/attachment.html>