Skip to content

Instantly share code, notes, and snippets.

@CliffordAnderson
Created March 10, 2017 21:01
Show Gist options
  • Save CliffordAnderson/25ab95e4cc398dbeb29e2ef600b3bcf1 to your computer and use it in GitHub Desktop.
Save CliffordAnderson/25ab95e4cc398dbeb29e2ef600b3bcf1 to your computer and use it in GitHub Desktop.
Fold Left for Anonymizing Names
xquery version "3.1";
(: The credit for this idea goes to Joe Wicentowski :)
let $sentence := "The men attending the meeting were Mr. Anderson, Mr. Wicentowski, and Mr. Jones. The women attending were Ms. French, Ms. Ryder, and Ms. Callon."
let $names := ("Anderson", "Jones", "French")
let $replace := function($sentence as xs:string?, $name as xs:string) as xs:string? {fn:replace($sentence, $name, "Smith")}
return fn:fold-left($names, $sentence, $replace)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment