Skip to content

Instantly share code, notes, and snippets.

View eneskarademir's full-sized avatar
🏠
Working from home

Enes Karademir eneskarademir

🏠
Working from home
View GitHub Profile
@kutyel
kutyel / iban.filter.js
Last active May 1, 2018 12:40
AngularJS filter to format IBAN accounts
(function() {
'use strict';
/**
* Formats a string and returns a valid IBAN account string
* @param {string} input example: 'ES0123456789012345678901'
* @return {string} output example: 'ES01 2345 6789 0123 4567 8901'
* @example <caption>{{'ES0123456789012345678901' | IBAN}}</caption>
*/
angular.module('app').filter('IBAN', () => iban => iban ? iban.replace(/[^\dA-Z]/g, '').replace(/(.{4})/g, '$1 ').trim() : '');