regex - checking whether a data is base64 encoded or not in nodejs -


i have check if string base 64 encoded or not below code

 var base64rejex =new regexp(/([a-za-z0-9+\/]{4})*([a-za-z0-9+\/]{4}|[a-za-z0-9+\/]{3}=|[a-za-z0-9+\/]{2}==$)/);  var base64data="rules"; var isbase64valid = base64rejex.test(base64data); // base64data base64 string  if (isbase64valid) { // true if base64 formate console.log('it base64'); var data=new buffer(base64data, 'base64').tostring('ascii') console.log("this is "+data) } else { // false if not in base64 formate console.log('it not in base64'); } 

even though above string not base 64 encoded,the output i'm receiving denoting base64 string. there thing need modify in regex? kindly help.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

android - Pass an Serializable object in AIDL -