Hi Geert, Thanks for the quick reply. The approach to use search:parse on the search string and then use search:unparse to convert it back to a search string worked perfectly. Thanks again!
Thanks, Blessing. On Wed, Jan 14, 2015 at 4:10 PM, Geert Josten <[email protected]> wrote: > Hi Blessing, > > I could be wrong, but I thought lookaheads are not supported in XPath: > > http://www.w3.org/TR/xpath-functions/#regex-syntax > > > I am guessing you are trying to get rid of the extra braces for better > user readability? A little more heavy, but potentially a very powerful > approach would be to use search:parse to turn the search string into a > query expression, manipulate that, and then use search:unparse to convert > it back to a search string. I have done so to apply term expansion.. > > Kind regards, > Geert > > On 1/14/15, 11:21 AM, "Blessing N" <[email protected]> wrote: > >>Hi, >> >>The positive lookahead regular expression which I have constructed >>below throws the following error >> >>[1.0-ml] XDMP-REGEX: (err:FORX0002) >>fn:replace("(search:"good") OR (search:"this(world) is >>good&q...", "\)(?=([^"]*["][^"]*["])*[^"]*$)", >>"") -- Invalid regular expression >> >>The Regex is >> >>let $str := '(search:"good") OR (search:"this(world) is good") OR >>(search:"world")' >>return fn:replace(fn:replace($str,'\)(?=([^"]*["][^"]*["])*[^"]*$)', >>""),'\((?=([^"]*["][^"]*["])*[^"]*$)', "") >> >>Expected result >> search:"good" OR search:"this(world) is good" OR >>search:"world" >> >>Basically I'm trying to remove the open and closed brackets withing >>the string but wanted them to be excluded if enclosed within double >>quotes. >> >>How to achieve positive lookahead using regex in Xquery? >> >>Thanks, >>Blessing. >>_______________________________________________ >>General mailing list >>[email protected] >>http://developer.marklogic.com/mailman/listinfo/general > > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
