Jump to content
Mad_Griffith

Object.values is not a function?

Recommended Posts

I don't seem to get my head around the reason why the following returns TypeError: Object.values is not a function

var input = '[a docs/my_pdf.pdf|here§my_class#my_id][img imgs/myimg.jpg|Alt title][g Artificial Languages][lang]HTML, CSS, Sass, SMACSS, SVG[y]7[/y][/lang][/g][p]Yes[/p]';

var RegEx = {
'tagClass': {
'\§\s*(.+?)\s*[\§\|\]\#]': ' class="$1"'
},
'tagId': {
'\#\s*(.+?)\s*[\§\|\]\#]': ' id="$1"'
},
'tagAlt': {
'\[img.+?\|\s*(.+?)\s*[\§\|\]\#]': ' alt="$1"'
},
'tagTitle': {
'\[a.+?\|\s*(.+?)\s*[\§\|\]\#]': ' title="$1"'
},
'tagSrc': {
'\[img\s*(.+?)\s*[\§\|\]\#]': ' src="$1"'
},
'tagHref': {
'\[a\s*(.+?)\s*[\§\|\]\#]': ' href="$1"'
},
'tagAngleBrackets': {
'\[(\/?)(.+?(?=[\]]))\]?': '<$1$2>'
}
};


for (var tag in RegEx) {
   input.replace(new RegExp(Object.keys(RegEx[tag])[0], 'g'), Object.values(RegEx[tag])[0]);
}
Edited by Mad_Griffith

Share this post


Link to post
Share on other sites

Ah, I see the second param should be a callback func. Is there any way to have the Object.values bit evaluated as a func?

 

edit: @justsomeguy, thanks! Could you suggest an alternative solution?

Edited by Mad_Griffith

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...