Advertisement
Guest User

46638582

a guest
Oct 8th, 2017
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.50 KB | None | 0 0
  1. php -a
  2. Interactive shell
  3.  
  4. php > $str="[@Homer Jay Simpson](id:homer) is a good guy.";
  5. php > preg_match('#(\[@([^\]])())#', $str, $matches);print_r($matches);
  6. Array
  7. (
  8.     [0] => [@H
  9.     [1] => [@H
  10.     [2] => H
  11.     [3] =>
  12. )
  13. php > preg_match('#(\[@([^\]+])())#', $str, $matches);print_r($matches);
  14. Array
  15. (
  16.     [0] => [@H
  17.     [1] => [@H
  18.     [2] => H
  19.     [3] =>
  20. )
  21. php > preg_match('#(\[@([^\]+]\])())#', $str, $matches);print_r($matches);
  22. Array
  23. (
  24. )
  25. php > preg_match('#(\[@([^\]]+)())#', $str, $matches);print_r($matches);
  26. Array
  27. (
  28.     [0] => [@Homer Jay Simpson
  29.     [1] => [@Homer Jay Simpson
  30.     [2] => Homer Jay Simpson
  31.     [3] =>
  32. )
  33. php > preg_match('#(\[@([^\]]+\])())#', $str, $matches);print_r($matches);
  34. Array
  35. (
  36.     [0] => [@Homer Jay Simpson]
  37.     [1] => [@Homer Jay Simpson]
  38.     [2] => Homer Jay Simpson]
  39.     [3] =>
  40. )
  41. php > preg_match('#(\[@[^\]]+())#', $str, $matches);print_r($matches);
  42. Array
  43. (
  44.     [0] => [@Homer Jay Simpson
  45.     [1] => [@Homer Jay Simpson
  46.     [2] =>
  47. )
  48. php > preg_match('#(\([@[^\]]+)\]())#', $str, $matches);print_r($matches);
  49. PHP Warning:  preg_match(): Compilation failed: unmatched parentheses at offset 16 in php shell code on line 1
  50.  
  51. Warning: preg_match(): Compilation failed: unmatched parentheses at offset 16 in php shell code on line 1
  52. Array
  53. (
  54.     [0] => [@Homer Jay Simpson
  55.     [1] => [@Homer Jay Simpson
  56.     [2] =>
  57. )
  58. php > preg_match('#(\([@[^\]]+)())#', $str, $matches);print_r($matches);
  59. PHP Warning:  preg_match(): Compilation failed: unmatched parentheses at offset 14 in php shell code on line 1
  60.  
  61. Warning: preg_match(): Compilation failed: unmatched parentheses at offset 14 in php shell code on line 1
  62. Array
  63. (
  64.     [0] => [@Homer Jay Simpson
  65.     [1] => [@Homer Jay Simpson
  66.     [2] =>
  67. )
  68. php > preg_match('#(\[@[^\]]+())#', $str, $matches);print_r($matches);
  69. Array
  70. (
  71.     [0] => [@Homer Jay Simpson
  72.     [1] => [@Homer Jay Simpson
  73.     [2] =>
  74. )
  75. php > preg_match('#(\[@([^\]]+)())#', $str, $matches);print_r($matches);
  76. Array
  77. (
  78.     [0] => [@Homer Jay Simpson
  79.     [1] => [@Homer Jay Simpson
  80.     [2] => Homer Jay Simpson
  81.     [3] =>
  82. )
  83. php > preg_match('#(\[@([^\]]+)\]())#', $str, $matches);print_r($matches);
  84. Array
  85. (
  86.     [0] => [@Homer Jay Simpson]
  87.     [1] => [@Homer Jay Simpson]
  88.     [2] => Homer Jay Simpson
  89.     [3] =>
  90. )
  91. php > echo $str;
  92. [@Homer Jay Simpson](id:homer) is a good guy.
  93. php > preg_match('#(\[@([^\]]+)\]\((id:([^)]+))\))#', $str, $matches);print_r($matches);
  94. Array
  95. (
  96.     [0] => [@Homer Jay Simpson](id:homer)
  97.     [1] => [@Homer Jay Simpson](id:homer)
  98.     [2] => Homer Jay Simpson
  99.     [3] => id:homer
  100.     [4] => homer
  101. )
  102. php > preg_match('#(\[@([^\]]+)\]\((?:id:([^)]+))\))#', $str, $matches);print_r($matches);
  103. Array
  104. (
  105.     [0] => [@Homer Jay Simpson](id:homer)
  106.     [1] => [@Homer Jay Simpson](id:homer)
  107.     [2] => Homer Jay Simpson
  108.     [3] => homer
  109. )
  110. php > preg_match('#(?:\[@([^\]]+)\]\((?:id:([^)]+))\))#', $str, $matches);print_r($matches);
  111. Array
  112. (
  113.     [0] => [@Homer Jay Simpson](id:homer)
  114.     [1] => Homer Jay Simpson
  115.     [2] => homer
  116. )
  117. php > preg_match('#(?:\[@([^\]]+)\]\(id:([^)]+)\))#', $str, $matches);print_r($matches);
  118. Array
  119. (
  120.     [0] => [@Homer Jay Simpson](id:homer)
  121.     [1] => Homer Jay Simpson
  122.     [2] => homer
  123. )
  124. php > preg_match('#\[@([^\]]+)\]\(id:([^)]+)\)#', $str, $matches);print_r($matches);
  125. Array
  126. (
  127.     [0] => [@Homer Jay Simpson](id:homer)
  128.     [1] => Homer Jay Simpson
  129.     [2] => homer
  130. )
  131. php > preg_match('#\[@([^\]]+)\]\(id:([^)]+)\)#', $str, $matches);print_r($matches);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement