How to validate IFSC Code using Regular Expression | Java program to validate IFSC ( Indian Financial System ) Code using regular expression . ; Function to validate IFSC ( Indian Financial System ) Code using regular expression . ; Regex to check valid IFSC Code . ; Compile the ReGex ; If the string is empty return false ; Pattern class contains matcher ( ) method to find matching between the given string and the regular expression . ; Return if the string matched the ReGex ; Driver Code . ; Test Case 1 : ; Test Case 2 : ; Test Case 3 : ; Test Case 4 :
import java . util . regex . * ; class GFG { public static boolean isValidIFSCode ( String str ) { String regex = " ^ [ A - Z ] { 4 } 0 [ A - Z0-9 ] { 6 } $ " ; Pattern p = Pattern . compile ( regex ) ; if ( str == null ) { return false ; } Matcher m = p . matcher ( str ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str1 = " SBIN0125620" ; System . out . println ( isValidIFSCode ( str1 ) ) ; String str2 = " SBIN0125" ; System . out . println ( isValidIFSCode ( str2 ) ) ; String str3 = "1234SBIN012" ; System . out . println ( isValidIFSCode ( str3 ) ) ; String str4 = " SBIN7125620" ; System . out . println ( isValidIFSCode ( str4 ) ) ; } }