Skip to content

Commit

Permalink
CAMEL-20845: camel-core - Simple language to make it easy to replace …
Browse files Browse the repository at this point in the history
…texts (#14412)
  • Loading branch information
davsclaus committed Jun 7, 2024
1 parent c2a682d commit 89dc81b
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
----

Expand All @@ -870,7 +873,7 @@ And to replace all single quotes with double quotes:
[source,xml]
----
<setBody>
<simple>${replace(&apos;,&quot;)}</simple>
<simple>${replace(&apos; , &quot;)}</simple>
</setBody>
----

Expand All @@ -879,7 +882,7 @@ Or to remove all double quotes:
[source,xml]
----
<setBody>
<simple>${replace(&quot;&empty;)}</simple>
<simple>${replace(&quot; , &empty;)}</simple>
</setBody>
----

Expand Down

0 comments on commit 89dc81b

Please sign in to comment.