dimanche 21 août 2016

Match word ending with either one of two special characters in the string

I'm trying to check if word. or word: is part of the string.

if (/wordb/.test(str) )

This is the best solution I came up with, but I'd like to match only for word. or word:.

I was trying something in the following lines, but can't get it to work:

if (/word/(.|:)/i.test(str)

How to go about this?

Aucun commentaire:

Enregistrer un commentaire