回答編集履歴
3
Update
test
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
negative lookahead(`?!`)
|
1
|
+
negative lookahead(`?!`) を利用する場合。
|
2
2
|
```php
|
3
3
|
//if(preg_match("/^\s*([\"'|'])[^\1]*?\g{1}\s*$/", $test)){
|
4
|
-
if(preg_match("/^\s*([\"'])(
|
4
|
+
if(preg_match("/^\s*([\"'])((?!\\1).)*\\1\s*$/", $test)){
|
5
5
|
```
|
2
Update
test
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
negative lookahead(`?!`) + make subpattern(`?:`)
|
2
2
|
```php
|
3
3
|
//if(preg_match("/^\s*([\"'|'])[^\1]*?\g{1}\s*$/", $test)){
|
4
|
-
if(preg_match("/^\s*([\"'])(?:(?!\\1).)
|
4
|
+
if(preg_match("/^\s*([\"'])(?:(?!\\1).)*\\1\s*$/", $test)){
|
5
5
|
```
|
1
Update
test
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
negative lookahead(`?!`) + make subpattern(`?:`)
|
1
2
|
```php
|
2
3
|
//if(preg_match("/^\s*([\"'|'])[^\1]*?\g{1}\s*$/", $test)){
|
3
4
|
if(preg_match("/^\s*([\"'])(?:(?!\\1).)+\\1\s*$/", $test)){
|