开发者

java regular expression [closed]

开发者 https://www.devze.com 2023-02-18 22:40 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its 开发者_如何学Gocurrent form.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its 开发者_如何学Gocurrent form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

How do I match a file name that does not end with a hyphen, using Java?


If you really, really need the regexp, this should do: .+[^-] (at least one character (any) followed by anything BUT hypen). It can be as complicated as you want to check for possible border cases, if needed.


Why would you need a regex for that? Especially in Java. You can just check whether a hyphen is the last character of the filename.


Try (any character at least one time plus the last one any character except '-'):

.+[^-]

0

精彩评论

暂无评论...
验证码 换一张
取 消