Regex usage in MongoDB
Background
Part1: Preface
Anyone who uses MySQL or other relational databases knows that fuzzy queries are used in similar ways:SELECT * FROM products WHERE sku like "% 789 ";
The regex in MongoDB described in this article
These two days in the demo. The function is implemented in a template (string Type, which is actually an SQL select query statement), and a regular expression is used to query fields that meet the conditions, then, replace other values with the
First, let's look at the sample SQL statement to be parsed:
Copy codeThe Code is as follows: select * from dual
SELECT * frOm dual
Select C1, c2 From tb
Select c1, c2 from tb
Select count (*) from t1
Select c1, c2, c3 from t1 where condi1 = 1
Select
What is a regular expression?Regular expressions, also known as formal representations, general representations (English: Regular Expression, often abbreviated as regex, RegExp, or re) in code, are a concept of computer science. A regular expression
First look at the sample SQL statement to parse:
Copy Code code as follows:
SELECT * FROM dual
SELECT * from dual
Select C1,C2 from TB
Select C1,C2 from TB
Select COUNT (*) from T1
Select c1,c2,c3 from t1 where condi1=1
The relationship between Regex and likeIn MySQL we often use regular expressions like filed '%?% '. But sometimes for regular filtering in complex scenarios, just a like looks a little bit out of hand.The essence of the Regex is ', like ' percent ' =
I. New. NET Class Library project
Create a class library project named Mssqlregexextend
Create a class named Regexextend
Copy the following code into the class[CSharp]View PlainCopy
Using System.Text.RegularExpressions;
Original address: http://www.cnblogs.com/rush/archive/2011/12/31/2309203.html1.1.1 SummaryRecently, the country's largest programmer community CSDN website user database was publicly released by hackers, 6 million of the user's login name and
There are three ways to implement regular expression matching in iOS. Now record them all here:
1. Using nspredicate (predicate) matchingFor example, to match a valid mailbox:
NSString *email = @ "nijino_saki@163.com";
nsstring *regex = @ "
1.1.1 SummaryRecently, the country's largest programmer community CSDN website user database was publicly released by hackers, 6 million of the user's login name and password was publicly disclosed, followed by a number of Web site user passwords
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.