嗨,我对正则表达式不太满意,在这里有点挣扎。我想测试一个字符串,看看它里面是否有'*',它只有一个,并且是字符串中的最后一个字符。
例如
'jflkasjkdfjkslf' // matches because it has no *
'*' // matches because it has a * and it is last character
'sdkfjksajdflkj*' // matches because it has a * and it is last character
'jasldk*aksjdf' // doesn't match because it has a * and it is not in last position
'asdjflkasjfd**' // doesn't match because it has more than one *
'asdjf*lkasjfd*' // doesn't match because it has more than one *
到目前为止,我(\*)$
只是测试它是否以*结尾,所以我还差得远...:(。
谢谢!
答案 0 :(得分:1)