This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 89dc81b7647 CAMEL-20845: camel-core - Simple language to make it easy
to replace texts (#14412)
89dc81b7647 is described below
commit 89dc81b76478f7da95f01899d017f11107dfdd40
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Jun 7 17:08:11 2024 +0200
CAMEL-20845: camel-core - Simple language to make it easy to replace texts
(#14412)
---
.../main/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 025a3aafa48..b0061ec90dd 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]
----
<setBody>
- <simple>${replace(',")}</simple>
+ <simple>${replace(' , ")}</simple>
</setBody>
----
@@ -879,7 +882,7 @@ Or to remove all double quotes:
[source,xml]
----
<setBody>
- <simple>${replace("∅)}</simple>
+ <simple>${replace(" , ∅)}</simple>
</setBody>
----