Vote count:
0
Given these strings:
var-nvar-ar var-nvar-br var-int-ar var-int-br oth-nvar-ar oth-nvar-br oth-int-ar oth-int-br
I would like to write a regex that selects all the strings that contain my substring if the substring is:
between the beginning of string and -
or
between -
and -
or
between -
and the end of the string
So if substring = 'var'
then the regex would select
var-nvar-ar var-nvar-br var-int-ar var-int-br
I tried:
strings = {'var-nvar-ar' 'var-nvar-br' 'var-int-ar' 'var-int-br' 'oth-nvar-ar' 'oth-nvar-br' 'oth-int-ar' 'oth-int-br'}
regexp(strings,'[^|(*?-)]var[(-.*)|$]','match')
but the result wasn't what I had in mind.
asked 48 secs ago
Aucun commentaire:
Enregistrer un commentaire