Hi,
you can try the below regex
isMatch (yourinputstring,'TR\d{2}[ ]\d{4}[ ]\d{4}[ ]\d{4}[ ]\d{4}[ ]\d{4}[ ]\d{2}|d{20}')
As addition to the great answer already provided I want to add that this does not actually validate an IBAN. To validate an IBAN there are some additional algorithms used and other validations. Explanation.
You could build a custom java action using the iban4j lib to verify an iban further:
import org.iban4j.IbanFormat;
import org.iban4j.IbanFormatException;
import org.iban4j.IbanUtil;
import org.iban4j.InvalidCheckDigitException;
import org.iban4j.UnsupportedCountryException;
import com.mendix.systemwideinterfaces.core.IContext;
import com.mendix.webui.CustomJavaAction;
/**
* IBAN validation based on the iban4j (v3.2.1) library.
*
* Params:
* IBANString: IBAN that needs to be verified
* defaultFormat: Default format requires groups of four characters separated by a single space to validate. If false formatting isn't required.
*
* Returns:
* True if IBAN is valid false if not.
*/
public class VerifyIBAN extends CustomJavaAction<java.lang.Boolean>
{
private java.lang.String IBANString;
private java.lang.Boolean defaultFormat;
public VerifyIBAN(IContext context, java.lang.String IBANString, java.lang.Boolean defaultFormat)
{
super(context);
this.IBANString = IBANString;
this.defaultFormat = defaultFormat;
}
@java.lang.Override
public java.lang.Boolean executeAction() throws Exception
{
// BEGIN USER CODE
boolean isSucces = true;
// try to validate Iban
try {
if (this.defaultFormat){
IbanUtil.validate(this.IBANString, IbanFormat.Default);
} else {
IbanUtil.validate(this.IBANString);
}
// valid
} catch (IbanFormatException |
InvalidCheckDigitException |
UnsupportedCountryException e) {
isSucces = false;
}
return isSucces;
// END USER CODE
}
/**
* Returns a string representation of this action
* @return a string representation of this action
*/
@java.lang.Override
public java.lang.String toString()
{
return "VerifyIBAN";
}
// BEGIN EXTRA CODE
// END EXTRA CODE
}