Select a character if some character from a list is before the character
问题 I have this regular expression: /([a-záäéěíýóôöúüůĺľŕřčšťžňď])-$\s*/gmi This regex selects č- from my text: sme! a Želiezovce 2015: Spoloíč- ne pre Európu. Oslávili aj 940. But I want to select only - (without č ) (if some character from the list [a-záäéěíýóôöúüůĺľŕřčšťžňď] is before the - ). 回答1: In other languages you would use a lookbehind /(?<=[a-záäéěíýóôöúüůĺľŕřčšťžňď])-$\s*/gmi This matches -$\s* only if it's preceded by one of the characters in the list. However, Javascript doesn't