|
Yes, I didn't notice but Erik did. You need to escape the "?" with "\?". The pattern should look like: "^/search\?q=".
-W
From: <Dunlap>, Zachariah <[email protected]>
Reply-To: MarkLogic Discussion <[email protected]> Date: Tuesday, July 30, 2013 11:36 AM To: MarkLogic Discussion <[email protected]> Subject: Re: [MarkLogic Dev General] fn:replace in QConsole I gave that a shot and it didn’t work either. Here’s what I tried in QConsole: xquery version "1.0-ml"; let $url := "/search?q=test" return fn:replace($url, "/search?q=", "/v1/search?options=appl&q=") Can you spot anything else I might be doing wrong? Thanks for your reply, Zach From:
[email protected] [mailto:[email protected]]
On Behalf Of Will Thompson Carrot and dollar are beginning of string/end of string anchors. So the _expression_ "^/search?q=$" will only match if there is no text preceding or following "/search?q=". If you want to allow text
to match following the _expression_, then remove the dollar anchor: "^/search?q=". Then it can match strings like "/search?q=my querystring". -Will From: <Dunlap>, Zachariah <[email protected]> I’m trying to test using fn:replace in QConsole and I’m hitting a small snag but can’t figure out where I’m going wrong. When I run this query in QConsole: xquery version "1.0-ml"; let $url := "/search?q=test" return fn:replace($url, "^/search?q=$", "/v1/search?options=appl&q=") I get back the string in $url and not the replacement, I can’t tell what I’m doing wrong. I’m using this query in the url rewrite section of one of our app servers and it works great: xquery version "1.0-ml"; let $url := xdmp:get-request-url() return fn:replace($url, "^/search$", "/login.xqy" This leaves me a bit stumped. Any help would be greatly appreciated. Thanks, Zach The information contained in this communication is intended for the use msk dccc60c6d2c3a6438f0cf467d9a4938 |
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
