English 中文(简体)
理解如下:
原标题:understanding the following regex
  • 时间:2010-08-26 08:14:35
  •  标签:
  • php
  • regex

我写了一篇论文,但是它不做预期的工作。 查询


preg_match_all("/([.:]?)(.{0,65}?[^s]*".preg_quote($word)."[^s]*.{0,65})/siu",$content,$matched);

[^s]*>preg_quote($word)[^s]

如果该部分包含关键词,例如与keyword相吻合,如果是搜索wor关键词,则该部分与整个字相吻合。

{0,65}?[^s]*”。 [^s]*{0,65}

i 在此,在关键词之前和之后,即达到65个特性。 i)

这里的很多话:


现在是问题。 如果在{65}号内有任何[:]特性,我就试图从起算起就判决。

如果有每个结构——第1字2:。 (19个月后) 关键词{此处的其他特性}

i 预计,如果是写到<代码>([:]?){0,65}? [^s]*{0,65}

它将与<代码>匹配。 关键词{65 特性}

但它没有<代码>部分[:]?n t对regex有任何影响。 它符合所有{65}特性。

有必要在关键词之前,在65个性范围内开始判决时,先从句起算。

最佳回答

[:]?系指“match a dot (,), a colon (:, or no”;如果下一个特性不是t or colon,([:]?)与否。 。 我认为,这是你回顾的:

$source= A regular expression (regex or regexp for short) is a special text string for describing a search pattern. You can think of regular expressions as wildcards on steroids. ;
$word =  regular ;
preg_match_all( #[^.:]{0,65} .preg_quote($word). .{0,65}#siu , $source, $matches);
print_r($matches);

产出:

Array
(
  [0] => Array
    (
      [0] => A regular expression (regex or regexp for short) is a special text string 
      [1] =>  You can think of regular expressions as wildcards on steroids.
    )

)

(见Ideone )

问题回答

简单地取代阴道

.{0,65}

页: 1

[^.:]{0,65}

毕竟, 或许可以这样看待。

preg_match_all("/([^.:]{0,65}?[^s]*".preg_quote($word)."[^s]*.{0,65})/siu",$content,$matched);




相关问题
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 ...