国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home Backend Development PHP Tutorial Regular expressions around-view assertion preview: How to correctly use forward and reverse preview?

Regular expressions around-view assertion preview: How to correctly use forward and reverse preview?

Apr 01, 2025 am 10:51 AM
ai the difference Why

Regular expressions around, assertions and pre-checks: In-depth understanding of forward and reverse pre-checks

This article explores the usage of Lookaround, assertions and pre-checks in regular expressions in in-depth manner, and clarifies some common misunderstandings. We will use "judgment strings that do not start with baidu or end with com " as an example to analyze the practical application and potential problems of forward negation pre-check and reverse negation pre-check.

Regular expressions around-view assertion preview: How to correctly use forward and reverse preview?

The article once mentioned using the regular expression ^(?!baidu).*$ determines strings that do not start with "baidu", and ^.*?( determines strings that do not end with "com". However, a key question is: Why is the forward pre-seeking before the matching string and the reverse pre-seeking after the matching string? This seems to be the opposite of conventional usage, and what is the practical significance of reverse negating pre-examination?

The key to the problem lies in insufficient understanding of forward and reverse pre-examination. ^(?!baidu).*$ means to match "not followed by the beginning of baidu (more precisely, the beginning of empty string)", and then match "arbitrary string" and "end". And ^.*?( means matching "start", "arbitrary string" (non-greedy match), and "previously not the end of <code>com ". The latter actually lacks meaning, because it is impossible to be com before the end of the string, so the expression is always true.

To explain more clearly, we compare the following examples:

^(?!baidu) matches "not followed by the beginning of baidu ". It only matches the beginning of the string and performs pre-checking, without actual matching.

^( matches "start", and only pre-checks are performed and do not participate in actual matching.

Therefore, the judgment does not start with "baidu", .*$ part can be omitted and judged with the partial matching function, for example in JavaScript:

/^(?!baidu)/.test('baidu.com'); // false

/^(?!baidu)/.test('www.baidu.com'); // true

/^(

The following examples further clarify the meaning and difference between forward and reverse pre-check:

The test results of /^www.(?=baidu).com$/ and /^www.(? are both <code>false because they try to match " www. followed by baidu " and "fronted .com baidu " respectively, and www.baidu.com does not meet these conditions.

The test result of /^www.(?=baidu)baidu.com$/ is true because (?=baidu) positive positive pre-examination ensures that www. is followed by baidu .

The test result of /^www.baidu(? is <code>true , because (? reverse sure pre-check ensures that <code>.com is front of baidu .

Through these examples, we can understand the location of forward and reverse pre-checks and their role in the matching process. The key is that the pre-review itself only makes judgments and does not participate in actual string matching. Misuses usually stem from misunderstandings about the pre-check mechanism.

The above is the detailed content of Regular expressions around-view assertion preview: How to correctly use forward and reverse preview?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to avoid risks in the turmoil in the currency circle? The TOP3 stablecoin list is revealed How to avoid risks in the turmoil in the currency circle? The TOP3 stablecoin list is revealed Jul 08, 2025 pm 07:27 PM

Against the backdrop of violent fluctuations in the cryptocurrency market, investors' demand for asset preservation is becoming increasingly prominent. This article aims to answer how to effectively hedge risks in the turbulent currency circle. It will introduce in detail the concept of stablecoin, a core hedge tool, and provide a list of TOP3 stablecoins by analyzing the current highly recognized options in the market. The article will explain how to select and use these stablecoins according to their own needs, so as to better manage risks in an uncertain market environment.

Global stablecoin market value PK! Who is the gold substitute in the bear market Global stablecoin market value PK! Who is the gold substitute in the bear market Jul 08, 2025 pm 07:24 PM

This article will discuss the world's mainstream stablecoins and analyze which stablecoins have the risk aversion attribute of "gold substitute" in the market downward cycle (bear market). We will explain how to judge and choose a relatively stable value storage tool in a bear market by comparing the market value, endorsement mechanism, transparency, and comprehensively combining common views on the Internet, and explain this analysis process.

The popularity of the currency circle has returned, why do smart people have begun to quietly increase their positions? Look at the trend from the on-chain data and grasp the next round of wealth password! The popularity of the currency circle has returned, why do smart people have begun to quietly increase their positions? Look at the trend from the on-chain data and grasp the next round of wealth password! Jul 09, 2025 pm 08:30 PM

As the market conditions pick up, more and more smart investors have begun to quietly increase their positions in the currency circle. Many people are wondering what makes them take decisively when most people wait and see? This article will analyze current trends through on-chain data to help readers understand the logic of smart funds, so as to better grasp the next round of potential wealth growth opportunities.

Virtual Currency Stable Coins Ranking Which is the 'safe haven' in the currency circle Virtual Currency Stable Coins Ranking Which is the 'safe haven' in the currency circle Jul 08, 2025 pm 07:30 PM

This article will introduce several mainstream stablecoins and explain in depth how to evaluate the security of a stablecoin from multiple dimensions such as transparency and compliance, so as to help you understand which stablecoins are generally considered relatively reliable choices in the market, and learn how to judge their "hazard-haven" attributes on your own.

Bitcoin breaks new highs, Dogecoin rebounds strongly, will Ethereum keep up with the pace Bitcoin breaks new highs, Dogecoin rebounds strongly, will Ethereum keep up with the pace Jul 09, 2025 pm 08:24 PM

Recently, Bitcoin hit a new high, Dogecoin ushered in a strong rebound and the market was hot. Next, we will analyze the market drivers and technical aspects to determine whether Ethereum still has opportunities to follow the rise.

Newbie buy coins and read this first! Comparison of the advantages and disadvantages of Bitcoin, Ethereum, Dogecoin Newbie buy coins and read this first! Comparison of the advantages and disadvantages of Bitcoin, Ethereum, Dogecoin Jul 09, 2025 pm 08:21 PM

For newbies who are new to digital assets, they often get into choice difficulties when facing various mainstream currencies. This article will compare the three popular currencies: Bitcoin, Ethereum, and Dogecoin in detail from the aspects of technical characteristics, usage scenarios, market evaluation, etc. to help users understand the main differences between them and their respective advantages and disadvantages.

What are the types of stablecoins? What are the stablecoins in digital currency? What are the types of stablecoins? What are the stablecoins in digital currency? Jul 08, 2025 pm 11:51 PM

Stable coins maintain price stability by anchoring fiat currencies such as the US dollar, which are mainly divided into three categories: 1. Fiat currency collateralization types such as USDT and USDC; 2. Cryptocurrency collateralization types such as DAI; 3. Algorithm types have higher risks. Mainstream stablecoins include USDT with the highest market value and the best liquidity. USDC is known for its compliance and transparency. DAI relies on the decentralized mechanism. TUSD adopts on-chain real-time audit. BUSD is gradually withdrawing from the market due to supervision. USDP is known for its high compliance and security. Both are widely circulated on mainstream exchanges.

What are the mainstream public chains of cryptocurrencies? The top ten rankings of cryptocurrency mainstream public chains in 2025 What are the mainstream public chains of cryptocurrencies? The top ten rankings of cryptocurrency mainstream public chains in 2025 Jul 10, 2025 pm 08:21 PM

The pattern in the public chain field shows a trend of "one super, many strong ones, and a hundred flowers blooming". Ethereum is still leading with its ecological moat, while Solana, Avalanche and others are challenging performance. Meanwhile, Polkadot, Cosmos, which focuses on interoperability, and Chainlink, which is a critical infrastructure, form a future picture of multiple chains coexisting. For users and developers, choosing which platform is no longer a single choice, but requires a trade-off between performance, cost, security and ecological maturity based on specific needs.

See all articles