简体   繁体   中英

Regular expression to pick extension

What would regular expression look like for any string which ends with .txt?
Tried few myself but it doesn't look like I'm getting anywhere.

I'd like to construct a regex object to feed a function.

.*\\.txt$类的东西:如果您想提高精度,我想您应该对一种语言和其他一些东西进行精度...

假设使用Perl样式的正则表达式,/ [^ \\。] * \\。txt $ /应该可以工作。

All you have to do is match the end of the string using

/\.txt$/

Matching more than that eg, .*\\.txt$ is not necessary

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM