0

My columns must contains 2 letter and 4 number like this (AV1234)

How can i check this ?

James Z
  • 12,209
  • 10
  • 24
  • 44
DY_BI
  • 3
  • 2
  • Why don't you use sql templates to do so – Talha Feb 09 '21 at 09:45
  • 2
    Please read [Under what circumstances may I add "urgent" or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) and find out why it often has the opposite effect. – jps Feb 09 '21 at 11:07

2 Answers2

0

You can use sql templates as mentioned in talend documentation here and you can check your column that contain letter and number using regular expressions.

Use this [a-zA-Z]{2}[0-9]{6}

Use this If you want only uppercase letters [A-Z]{2}[0-9]{6}

[a-zA-Z]    # Match a single character present in the list below
            # A character in the range between “a” and “z”
            # A character in the range between “A” and “Z”
  {2}       # Exactly 2 times
[0-9]       # Match a single character in the range between “0” and “9”
  {6}       # Exactly 6 times

Talha
  • 524
  • 1
  • 6
  • 22
0

Thank you for your answer ! it Works

My routine code:

public static Boolean MyPattern(String str) {


String stringPattern = "[A-Z]{2}[0-9]{4}"; 

boolean match = Pattern.matches(stringPattern, str);


return match ;

  }
Talha
  • 524
  • 1
  • 6
  • 22
DY_BI
  • 3
  • 2