Seek regular $aaa =bbb change aaa= "BBB"

Source: Internet
Author: User
1 For example $table =channel
Become $table =channel

2 For example $Row =10
Become $Row =10

3 For example $table =channel
Become $table =channel

Structure description
The original structure must be End (the left side of > may or may not exist) the part within this structure does not change
To seek the regular

I wrote one, but it wasn't perfect.
$p = '/\$ (\w+) = (\w+)/I ';
$r = ' $1= ';
$c = Preg_replace ($p, $r, $c);

The where=[fatherid]=0 section cannot be matched to determine if the Internal

Can match the above three examples to all points


Reply to discussion (solution)

$SQL =select * FROM [{pre}content] where [CID] in (3,4,5)
This does not have the demarcation symbol, cannot judge, finally adds a semicolon

 
          $table =channel
 
          
           
  $Row =10
  
           
            
    $table =channel '; Echo preg_replace (  Array ('/(<.*) \$ (row= (\d+) (.*>)/', '/(<.*) \$ (table=) (\w+) (.*>)/', '/(<.*) \$ (where=) (\[\w+\]=) (\d+) (.*>)/', '/(<.*) \ $ (type=) (\w+) (.*>)/', '/(<.*) \$ (sql=) (. *;) (.*>)/'),  array (' $1$2 ' $ "$4 ', ' $1$2 ' $" $4 ', ' $1$2 ' $3$4 "$" , ' $1$2 ' $ "$4 ', ' $1$2 '" $ $4 '),  $s);? >
  
           
 
          



$table =channel
$Row =10
$table =channel

$SQL =select * FROM [{pre}content] where [CID] in (3,4,5)
This does not have the demarcation symbol, cannot judge, finally adds a semicolon

 
             $table =channel
 
             
              
  $Row =10
  
              
               
    $table =channel '; Echo preg_replace (  Array ('/(<.*) \$ (row= (\d+) (.*>)/', '/(<.*) \$ (table=) (\w+) (.*>)/', '/(<.*) \$ (where=) (\[\w+\]=) (\d+) (.*>)/', '/(<.*) \ $ (type=) (\w+) (.*>)/', '/(<.*) \$ (sql=) (. *;) (.*>)/'),  array (' $1$2 ' $ "$4 ', ' $1$2 ' $" $4 ', ' $1$2 ' $3$4 "$" , ' $1$2 ' $ "$4 ', ' $1$2 '" $ $4 '),  $s);? >
  
              
 
             



$table =channel
$Row =10
$table =channel






I have a train of thought. See if you can improve the semicolon.

You can use the $AA =BB $ to split
first Middle Part of the proposed
at the end of the add $ and then split
$Row =10 $table =channel $Where =[fatherid]=0 $
So you see can be improved under Thank you

you have to make sure there is a $ to go, thinking you have come up with my change is not difficult.
Refueling.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.