字符串到RegEx转换

时间:2018-05-08 09:59:08

标签: php regex

(name eq "xxxx" and user:(post.id eq 6 and post.post eq "testing") and data eq "Hello World!")

我有上面的字符串,我想通过RegEx过滤它以获得以下输出:

[
 [
   "name eq "xxxx"",
   "user" => [
       "post.id eq 6",
       "post.post eq testing",
   ],
   "data eq "Hello World!"",
 ],
 [
   "name",
   "user" => [
        post.id,
        post.post
   ],
   "data",
 ],
]

我尝试了以下正则表达式解决方案

/([\\w\\.]+)[\\s]+(?:eq)[\\s]+(?:"(?:[^"\\\\]|\\\\.)*"|\\d+(?:,\\d+)*(?:\\.\\d+(?:e\\d+)?)?|null)/i

得到了值

[
[
  "name eq "xxxx"",
  "post.id eq 6",
  "post.post eq "testing"",
],
[
  "name",
  "post.id",
  "post.post",
],
]

1 个答案:

答案 0 :(得分:1)

尝试这个,我试着检查正则表达式

========== Preparing Containers ==========
Getting Docker containers ready...
<snip>
Step 1/4 : FROM microsoft/aspnet:4.7.1-windowsservercore-1709
<snip>
Successfully built cbde0ec28022
<snip>
Done!  Docker containers are ready.