且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用正则表达式进行搜索,就像在SQL中一样

更新时间:2023-09-28 12:05:04

在这种情况下,请尝试:
In this case, try:
ClosedAccountFile_(\d+)_(\d+)_(\d+)_(\d+).txt

.这与您的示例相符,并将每个数字值都分离出来.在比赛中属于自己的组.

您已经认识到Regexes比SQL LIKE语句复杂得多,在Regext中最简单的%"形式是.*",它可以匹配任意数量的任何字符:通常有更好的方法可以在正则表达式.

获取 Expresso [ ^ ]-它是免费的,它可以检查并生成正则表达式.

This matches your example, and separates each of the numeric values out into it''s own group within the match.

You have top realize that Regexes are much, much more complex than SQL LIKE statements - the simplest form of "%" in a Regext is ".*" which matches any number of any character: there are normally better ways to do this in a Regex.

Get a copy of Expresso [^] - it''s free, and it examines and generates Regular expressions.


(.*)似乎可以正常工作%在SQL中有效.
感谢您的回答.
(.*) seems like working as % works in SQL.
Thanks for the answer.