I’m trying to create a function that will search a string for anexpression such as "zz(aa|bb)zz"so “yyzzaazzau” sss “zz(aa|bb)zz” would return ,2 (similar to the ssfunction) just with the inclusion of OR and matching two charactersinstead of just single characters.My first solution was terrible as I created a list of all possibleacceptable combinations of the string from the expression. So for myexample -“zzaazz”"zzbbzz"but it spiraled out of control when I added more complex pattern -“zz(aa|bb|cc)xx(dd|cc)uu” would lead to six possible combinationsetc…As my initial idea failed, if anybody could suggest a particular angleto attempt this from I’d appreciate it!Thanks
Hi,
If q external libraries are an option for you, please have a look at some regular expression ports (PCRE) to q;
http://thesweeheng.wordpress.com/2008/07/14/regular-expressions-for-q/
This solution opens ‘pattern matching’ doors wider and is very neat.
Cheers,
Patryk
You can also port the boost library boost.regex to Q.
Am 27.03.2012 09:41, schrieb Patryk Bukowinski:
Hi,
If q external libraries are an option for you, please have a look at some regular expression ports (PCRE) to q;
http://thesweeheng.wordpress.com/2008/07/14/regular-expressions-for-q/
This solution opens ‘pattern matching’ doors wider and is very neat.
Cheers,
Patryk
PCRE is very useful, thanks!I’m also attempting to port the boost.regex library to Q, however I’mhaving some problems extending Q with C++.just writing a basic c++ program along the lines of#include "k.h"K f(K x){ return ki(10);}On linux I’m compiling usinggcc -I /path/my/folder -shared -fPIC myfile.cpp -o ~/q/l32/myfile.soHowever, when I run func:myfile 2:(
func;1) I just get undefinedsymbol f, no matter what I try.Thanks, OllieOn Mar 28, 8:26?pm, Kim Kuen Tang <kuent…> wrote:> You can also port the boost library boost.regex to Q.>> Am 27.03.2012 09:41, schrieb Patryk Bukowinski:>>>>>>>>>> > Hi,>> > If q external libraries are an option for you, please have a look at> > some regular expression ports (PCRE) to q;>> >http://q.o.potam.us/?p=pcre>> >http://thesweeheng.wordpress.com/2008/07/14/regular-expressions-for-q/>> > This solution opens ‘pattern matching’ doors wider and is very neat.>> > Cheers,> > Patryk>> > On Mar 23, 2012 1:38 PM, “oli.l” <ollie920…> > mailto:ollie920...> wrote:>> > ? ? I’m trying to create a function that will search a string for an> > ? ? expression such as “zz(aa|bb)zz”>> > ? ? so “yyzzaazzau” sss “zz(aa|bb)zz” would return ,2 (similar to the ss> > ? ? function) just with the inclusion of OR and matching two characters> > ? ? instead of just single characters.>> > ? ? My first solution was terrible as I created a list of all possible> > ? ? acceptable combinations of the string from the expression. So for my> > ? ? example -> > ? ? “zzaazz”> > ? ? “zzbbzz”> > ? ? but it spiraled out of control when I added more complex pattern -> > ? ? “zz(aa|bb|cc)xx(dd|cc)uu” would lead to six possible combinations> > ? ? etc…>> > ? ? As my initial idea failed, if anybody could suggest a particular angle> > ? ? to attempt this from I’d appreciate it!>> > ? ? Thanks>> > ? ? –> > ? ? You received this message because you are subscribed to the Google> > ? ? Groups “Kdb+ Personal Developers” group.> > ? ? To post to this group, send email to> > ? ? personal-kdbplus@googlegroups.com> > ? ? mailto:personal-kdbplus.> > ? ? To unsubscribe from this group, send email to> > ? ? personal-kdbplus+unsubscribe@googlegroups.com> > ? ? mailto:personal-kdbplus.> > ? ? For more options, visit this group at> > ? ?http://groups.google.com/group/personal-kdbplus?hl=en.>> > –> > You received this message because you are subscribed to the Google> > Groups “Kdb+ Personal Developers” group.> > To post to this group, send email to personal-kdbplus@googlegroups.com.> > To unsubscribe from this group, send email to> > personal-kdbplus+unsubscribe@googlegroups.com.> > For more options, visit this group at> >http://groups.google.com/group/personal-kdbplus?hl=en.</mailto:personal-kdbplus></mailto:personal-kdbplus></mailto:ollie920…></ollie920…></kuent…>
#include “k.h”
extern “C” K f(K x){
return ki(10);
}