Remove all special characters except percentage (real time use case)?

How to remove all special characters except percentage (real time use case)? If you are running a coupon website, then you will have this issue sometime while parsing/scrapping coupons from merchants.   For example, you will have these three types of strings: 1. Get 10% Cashback 2. Get Rs. 10/- Cashback 3. Get 10/- Cashback 4. Get (Indian rupee symbol)

215 total views, 1 views today

» Read more

Java Program to find two letter capital words using Regex

Java Program to find two letter capital words in Java using Regex: import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexAppealAddress { public static void main(String[] args) { String input = "Javadomain is also called as JD which contains JAVA tutorials and programmings"; // This prints JD and JA // Pattern regexPattern = Pattern.compile("\\s[A-Z]{2,2}"); // This prints only JD Pattern regexPattern =

152 total views, no views today

» Read more

Java Regex Pattern to allow characters and spaces Example

Java Regex Pattern to allow characters and spaces Example: Requirements: Java domain – Should be allowed – Should Not allowed Java – Should be allowed (Java) – Should Not allowed Javadomain – Should be allowed Java Regex Program to allow characters and whitespaces And also not allow only whitespaces: import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexSpace { public static void

271 total views, no views today

» Read more

Java Regex Pattern Example

Regex [Regular Expression]: Regular expression is a useful one to match and extract only the required parts. Eg: Defining the phone number formats. Removing unreadable or unwanted characters from a string Sample Program: import java.util.regex.Matcher; import java.util.regex.Pattern; public class Regex { public static void main(String[] args) { String inputStr = "?Javadomain.in’s a technical,java-blog"; Pattern pattern = Pattern.compile("[\\s\\?\\,\\-\\’]+"); Matcher matcher =

230 total views, 1 views today

» Read more

Java regex to check empty end of url

Program Description: This program takes the end value from the url. Program: import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexEmptyEnd { public static String myurl = "http://javadomain.in/regexpage&page=8372528"; public static void main(String[] args) { String regex = "page=(.*?)$"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(myurl); if (matcher.find()) { String str = matcher.group(1); System.out.println("page is "+str); } } }   Output: page

137 total views, no views today

» Read more