As a simple example, this will replace any instance of "$<any digits>," with 
"$<the digits>".

fn:replace("$10,000 value $6,000, Not able to find other", "\$(\d+),", "\$$1");

Produces: "$10000 value $6000, Not to find other"

This won't work with anything over $999,999, though.  It will only replace the 
first comma, not the second one.

More generically, you could look for any sequence of three numbers with a comma 
in front of them and replace that with just the digits.

fn:replace("$10,000 value $6,000, Not able $9,934,034 to find other", 
",(\d{3})", "$1");

Produces:  "$10000 value $6000, Not able $9934034 to find other"

Eric


From: [email protected] 
[mailto:[email protected]] On Behalf Of 
[email protected]
Sent: August 03, 2017 08:33
To: [email protected]
Subject: [**EXTERNAL**] [MarkLogic Dev General] special character using 
fn:replace and regex

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

Reply via email to