My JSF Books/Videos My JSF Tutorials OmniFaces/JSF PPTs
JSF 2.3 Tutorial
JSF Caching Tutorial
JSF Navigation Tutorial
JSF Scopes Tutorial
JSF Page Author Beginner's Guide
OmniFaces 2.3 Tutorial Examples
OmniFaces 2.2 Tutorial Examples
JSF Events Tutorial
OmniFaces Callbacks Usages
JSF State Tutorial
JSF and Design Patterns
JSF 2.3 New Features (2.3-m04)
Introduction to OmniFaces
25+ Reasons to use OmniFaces in JSF
OmniFaces Validators
OmniFaces Converters
JSF Design Patterns
Mastering OmniFaces
Reusable and less-verbose JSF code

My JSF Resources ...

Java EE Guardian
Member of JCG Program
Member MVB DZone
Blog curated on ZEEF
OmniFaces is an utility library for JSF, including PrimeFaces, RichFaces, ICEfaces ...

.

.

.

.

.

.

.

.


[OmniFaces Utilities] - Find the right JSF OmniFaces 2 utilities methods/functions

Search on blog

Petition by Java EE Guardians

Twitter

luni, 7 septembrie 2015

[OmniFaces utilities 2.0] Replace all matches of the given pattern on the given string with the given replacement


[OmniFaces utilities] The replaceAll() function replaces all matches of the given pattern on the given string with the given replacement.

Function:
Usage:

Let's suppose that we have the following string:

<c:set var="text" value="This is a String to use as an example to present raplaceAll"/>

Replacing single characters

·         replace all occurrences of 'a' with '@'

#{of:replaceAll(text, "a", "@")}
Result: This is @ String to use @s @n ex@mple to present r@pl@ceAll

·         replace all occurrences of 'e' with '3'

#{of:replaceAll(text, "e", "3")}
Result: This is a String to us3 as an 3xampl3 to pr3s3nt raplac3All

·         replace all occurrences of 't' with 'T'

#{of:replaceAll(text, "t", "T")}
Result: This is a STring To use as an example To presenT raplaceAll

·         remove all occurrences of 'o'

#{of:replaceAll(text, "o", "")}
Result: This is a String t use as an example t present raplaceAll

·         replace all occurrences of 't' with 'That'

#{of:replaceAll(text, "t", "That")}
Result: This is a SThatring Thato use as an example Thato presenThat raplaceAll

Replacing char sequences character

·         replace all occurrences of 'This' with 'That'

#{of:replaceAll(text, "This", "That")}
Result: That is a String to use as an example to present raplaceAll

·         replace all occurrences of 'String' with 'big String'

#{of:replaceAll(text, "String", "big String")}
Result: This is a big String to use as an example to present raplaceAll

·         remove all occurrences of 'is'

#{of:replaceAll(text, "is", "")}
Result: Th a String to use as an example to present raplaceAll

·         remove all occurrences of 'replaceAll'

#{of:replaceAll(text, "raplaceAll", "")}
Result: This is a String to use as an example to present

Using regular expressions

·         replace uppercase letters with '-'

#{of:replaceAll(text, "[A-Z]+", "-")}
Result: -his is a -tring to use as an example to present raplace-ll

Niciun comentariu :

Trimiteți un comentariu

JSF BOOKS COLLECTION

Postări populare

OmniFaces/JSF Fans

Visitors Starting 4 September 2015

Locations of Site Visitors