Someimport java.util.regex.Matcher;
import java.util.regex.Pattern;
class changeTypeFeild1 {
static boolean allCharactersSame(String s)
{
int n = s.length();
for (int i = 1; i < n; i++)
if (s.charAt(i) != s.charAt(0))
return false;
return true;
}
String CheckJunk(String s){
Pattern pattern = Pattern.compile("\\d{9}");
Matcher matcher = pattern.matcher(s);
if (!matcher.matches() || allCharactersSame(s)==true||s.startsWith("00")) {
return "qqq";
}
else
return s;
}
}
public class sample2 {
public static void main(String[] args) {
changeTypeFeild1 ch = new changeTypeFeild1();
System.out.println(ch.CheckJunk("11111111111"));
}
}
class changeTypeFeild {
String changeTypeFeilds(String s) {
if (s.equals("OB")) {
return "Opt Blue";
} else if (s.equals("OP")) {
return "One Point";
} else {
return s;
}
}
}
public class Sample1 {
public static void main(String[] args) {
changeTypeFeild ch = new changeTypeFeild();
System.out.println(ch.changeTypeFeilds("Temp"));
}
}
_____&'&&&&&&&
1234567891-->1234567891
+11234567891-->1234567891
2345678910000-->234567891
23456789100001-->empty
import java.util.regex.Matcher;
import java.util.regex.Pattern;
class CatalystFunction12 {
public static String isCheckLeading(String s) {
Pattern pattern = Pattern.compile("\\d{10}");
Matcher matcher = pattern.matcher(s);
if (!matcher.matches() && s.length() < 10) {
return "small empty";
} else if (!matcher.matches() && s.length() > 10 && s.startsWith("+1") | s.startsWith("1")) {
String t = s.replaceFirst("[+]1|1", "");
return t;
} else if (!matcher.matches() && s.length() > 10 && s.endsWith("0")) {
String t = s.replaceAll("0*$", "");
return t;
}else if (!matcher.matches()) {
return "";
}
else {
return s;
}
}
}
public class Sample3 {
public static void main(String[] args) {
CatalystFunction12 c = new CatalystFunction12();
System.out.println(c.isCheckLeading("23456789100001"));
}
}
==========================================
package com.aexp.cpip.transformation.catalyst;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PhoneorReplace implements CatalystFunction<String> {
public PhoneorReplace() {
}
public String apply(String columnValue, Map<String, Object> paramMap) throws CatalystFunctionException {
Pattern pattern = Pattern.compile("\\d{10}");
Matcher matcher = pattern.matcher(columnValue);
if (!matcher.matches() && columnValue.length() < 10) {
return "";
} else if (!matcher.matches() && columnValue.length() > 10 && columnValue.startsWith("+1") | columnValue.startsWith("1")) {
String mvFirstEle = columnValue.replaceFirst("[+]1|1", "");
return mvFirstEle;
} else if (!matcher.matches() && columnValue.length() > 10 && columnValue.endsWith("0")) {
String mvlastEle = columnValue.replaceAll("0*$", "");
return mvlastEle;
}else if (!matcher.matches()) {
return "";
}
else {
return columnValue;
}
}
}
No comments:
Post a Comment