How to validate IFSC Code using Regular Expression | C ++ program to validate the IFSC ( Indian Financial System ) Code using Regular Expression ; Function to validate the IFSC ( Indian Financial System ) Code . ; Regex to check valid IFSC ( Indian Financial System ) Code . ; If the IFSC ( Indian Financial System ) Code is empty return false ; Return true if the IFSC ( Indian Financial System ) Code matched the ReGex ; Driver Code ; Test Case 1 : ; Test Case 2 : ; Test Case 3 : ; Test Case 4 :
#include <iostream> NEW_LINE #include <regex> NEW_LINE using namespace std ; bool isValidIFSCode ( string str ) { const regex pattern ( " ^ [ A - Z ] { 4 } 0 [ A - Z0-9 ] { 6 } $ " ) ; if ( str . empty ( ) ) { return false ; } if ( regex_match ( str , pattern ) ) { return true ; } else { return false ; } } int main ( ) { string str1 = " SBIN0125620" ; cout << boolalpha << isValidIFSCode ( str1 ) << endl ; string str2 = " SBIN0125" ; cout << boolalpha << isValidIFSCode ( str2 ) << endl ; string str3 = "1234SBIN012" ; cout << boolalpha << isValidIFSCode ( str3 ) << endl ; string str4 = " SBIN7125620" ; cout << boolalpha << isValidIFSCode ( str4 ) << endl ; return 0 ; }