English 中文(简体)
为什么使用“不”和背后法,这种reg需要一个 la子?
原标题:Why does this regex, using "not" & a backref, require a lazy match?

在使用“<代码>><>>>/代码”的操作人员时,加上背心,为什么我需要使用“zy匹配”? 似乎如<代码>而不是。 应当打破这种对比。

例如:

<?php
preg_match( /(t)[^1]*1/ ,  is this test ok , $matches);
echo $matches[0];
?>

<http://codepad.viper-7.com/BPDeLx” rel=“nofollow noreferer”>>>> Will输出this test, 而不是t t,尽管中文本<>t 与[^1]不一致。 我们需要使用>/(t)[^1]*?<1/code>,以便与<编码>相匹配。

而且

preg_match( /t[^t]*t/ ,  is this test ok , $matches);

doescomp only this t

正在发生什么,我有什么误解?

最佳回答

之所以没有工作,是因为此处的<代码>1不是特性类别中的背书。 <代码>1被解释为具有ASCII值的特性。

你可以采取消极态度,而是要取得你想要的效果:

 /(t)(?:(?!1).)*1/ 
问题回答

您不能在品行内使用背书。 <代码>[^1]系指“除<代码>1以外的任何特性”。

相反,使用<条码>/(t)(?:!?”

<代码>(?:......)

(?!) is a “negative look-ahead”, claiming that the subexpression doesn t对等

<代码>1为单一特性时,指“与<代码>1不一致的任何特性”。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...