I have a string of 'image/png'
, the 'png'
could also be 'jpg'
'gif'
'jpeg'
. I have a new RegExp(/^image[/](jpe?g|gif|png)$/)
which seems to work for the most part.
I use the .match()
method and it returns an array like so ['image/png', 'png']
. I want it to return an array with ['image/png']
. I looked up some other post and saw the recommended ^$
for beginning and end and even tried the \b
which is I think some type of word bound special character.
None of these are returning only the one match, which is what I want.
Expressions that should work:
'image/png' should return from match ['image/png'] not ['image/png', 'png']
'image/jpg' should return from match ['image/jpg'] not ['image/jpg', 'jpg']
'image/jpeg' should return from match ['image/jpeg'] not ['image/jpeg', 'jpeg']
'image/gif' should return from match ['image/gif'] not ['image/gif', 'gif']