From 0a5526ea23635ba0f03b39d4291a67c233bf855c Mon Sep 17 00:00:00 2001 From: buddhini81 Date: Mon, 22 May 2017 08:49:36 +0530 Subject: [PATCH] Add class EscapingChars for BAEL-839 --- .../com/baeldung/regexp/EscapingChars.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 core-java/src/main/java/com/baeldung/regexp/EscapingChars.java diff --git a/core-java/src/main/java/com/baeldung/regexp/EscapingChars.java b/core-java/src/main/java/com/baeldung/regexp/EscapingChars.java new file mode 100644 index 0000000000..3268339a15 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/regexp/EscapingChars.java @@ -0,0 +1,25 @@ +package com.baeldung.regexp; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class EscapingChars { + public boolean isMatching(String input, String pattern) { + return input.matches(pattern); + } + + public int splitAndCountWords(String input, String pattern) { + return input.split(pattern).length; + } + + public int splitAndCountWordsUsingQuoteMethod(String input, String pattern) { + return input.split(Pattern.quote(pattern)).length; + } + + public String changeCurrencySymbol(String input, String pattern, + String correctStr) { + Pattern p = Pattern.compile(pattern); + Matcher m = p.matcher(input); + return m.replaceAll(correctStr); + } +}