From 89dc81b76478f7da95f01899d017f11107dfdd40 Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Fri, 7 Jun 2024 17:08:11 +0200 Subject: [PATCH] CAMEL-20845: camel-core - Simple language to make it easy to replace texts (#14412) --- .../docs/modules/languages/pages/simple-language.adoc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-language.adoc b/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-language.adoc index 025a3aafa4841..b0061ec90dd2d 100644 --- a/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-language.adoc +++ b/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-language.adoc @@ -854,14 +854,17 @@ You can nest functions, such as shown below: === Replacing double and single quotes -You can use the `replace` function to more easily replace all single or double quotes in the message body. +You can use the `replace` function to more easily replace all single or double quotes in the message body, +using the XML escape syntax. This avoids to fiddle with enclosing a double quote or single quotes with outer quotes, +that can get confusing to be correct as you may need to escape the quotes as well. So instead you can use the XML escape +syntax where double quote is `\"` and single quote is `\'` (yeah that is the name). For example to replace all double quotes with single quotes: [source,java] ---- from("direct:order") - .transform().simple("${replace(",')}") + .transform().simple("${replace(" , ')}") .to("mock:reply"); ---- @@ -870,7 +873,7 @@ And to replace all single quotes with double quotes: [source,xml] ---- - ${replace(',")} + ${replace(' , ")} ---- @@ -879,7 +882,7 @@ Or to remove all double quotes: [source,xml] ---- - ${replace("∅)} + ${replace(" , ∅)} ----