Skip to content

Commit 6f2a9f3

Browse files
committed
Use non-capturing subpatterns
1 parent b174ad3 commit 6f2a9f3

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/VerbalExpressions/PHPVerbalExpressions/VerbalExpressions.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function endOfLine($enable = true)
9090
*/
9191
public function then($value)
9292
{
93-
return $this->add("(".self::sanitize($value).")");
93+
return $this->add("(?:".self::sanitize($value).")");
9494
}
9595

9696
/**
@@ -114,7 +114,7 @@ public function find($value)
114114
*/
115115
public function maybe($value)
116116
{
117-
return $this->add("(".self::sanitize($value).")?");
117+
return $this->add("(?:".self::sanitize($value).")?");
118118
}
119119

120120
/**
@@ -127,7 +127,7 @@ public function maybe($value)
127127
*/
128128
public function anything()
129129
{
130-
return $this->add("(.*)");
130+
return $this->add("(?:.*)");
131131
}
132132

133133
/**
@@ -141,7 +141,7 @@ public function anything()
141141
*/
142142
public function anythingBut($value)
143143
{
144-
return $this->add("([^". self::sanitize($value) ."]*)");
144+
return $this->add("(?:[^". self::sanitize($value) ."]*)");
145145
}
146146

147147
/**
@@ -154,7 +154,7 @@ public function anythingBut($value)
154154
*/
155155
public function something()
156156
{
157-
return $this->add("(.+)");
157+
return $this->add("(?:.+)");
158158
}
159159

160160
/**
@@ -168,7 +168,7 @@ public function something()
168168
*/
169169
public function somethingBut($value)
170170
{
171-
return $this->add("([^". self::sanitize($value) ."]+)");
171+
return $this->add("(?:[^". self::sanitize($value) ."]+)");
172172
}
173173

174174
/**
@@ -203,7 +203,7 @@ public function replace($source, $value)
203203
*/
204204
public function lineBreak()
205205
{
206-
return $this->add("(\\n|(\\r\\n))");
206+
return $this->add("(?:\\n|(\\r\\n))");
207207
}
208208

209209
/**
@@ -417,14 +417,14 @@ public function multiple($value)
417417
public function _or($value)
418418
{
419419
if (strpos($this->prefixes,"(")===false) {
420-
$this->prefixes .= "(";
420+
$this->prefixes .= "(?:";
421421
}
422422

423423
if (strpos($this->suffixes, ")")===false) {
424424
$this->suffixes .= ")";
425425
}
426426

427-
$this->add(")|(");
427+
$this->add(")|(?:");
428428

429429
if ($value) {
430430
$this->add($value);

0 commit comments

Comments
 (0)