You need to use regex capture groups.  Try something like this:

declare variable $input := "$10,000,000 value $6,000 , Not able to find
other";

declare variable $regex := ",([0-9]+)";
declare variable $replace := "$1";

(: declare variable $regex := "\$(([0-9]+),)*([0-9]+)"; :)
(: declare variable $replace := "\$$2$3"; :)

fn:replace ($input, $regex, $replace)

   The uncommented version will handle an arbitrary number of commas, but
is a looser match.  It will match anything that has a comma followed by a
series of numbers, not just dollar amounts.

   The commented version looks for dollar signs but will only filter out
the first comma in the number.

   To be more stringent than that you may need to write some custom code.

----
Ron Hitchens [email protected], +44 7879 358212


On August 3, 2017 at 3:42:57 PM, [email protected] (
[email protected]) wrote:

Hi All,



How to replace special character using fn:replace and value .I want to
remove special character “,”  for both the $ values but other”,” should
exist .



Example:

Input : " $10,000 value $6,000 , Not able to find other"



After using functx library I am able to get “$10” and ”$6” now I want to
replace these corresponding value to “$10,000” and “$6,000” respectively



I am using fn:replace($input,”$10,”,$10)

but unable to replace “$10,” with “$10”

output : $10000 value $6000 , Not able to find other




This e-mail and any files transmitted with it are for the sole use of the
intended recipient(s) and may contain confidential and privileged
information. If you are not the intended recipient(s), please reply to the
sender and destroy all copies of the original message. Any unauthorized
review, use, disclosure, dissemination, forwarding, printing or copying of
this email, and/or any action taken in reliance on the contents of this
e-mail is strictly prohibited and may be unlawful. Where permitted by
applicable law, this e-mail and other e-mail communications sent to and
from Cognizant e-mail addresses may be monitored.
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to