PHP uses regular expressions to extract four columns of data in batches to import data into the MySQL database

Source: Internet
Author: User
PHP uses regular expressions to extract four of columns of data, and to bulk import data into MySQL database

>>>>[0601_Access_S5352]dis arp>>>>IP ADDRESS      MAC ADDRESS  EXPIRE(M) TYPE INTERFACE      VPN-INSTANCE>>>>-------------------------------------------------------------------------->>>>192.168.66.11   0016-413e-0c62         SF-  GE0/0/23                 66>>>>192.168.66.13   0019-b906-e2ec         S--  GE0/0/18                 66>>>>192.168.66.15   0019-b906-be56         S--  GE0/0/16                 66>>>>192.168.66.17   0018-8b1e-96df         SF-  GE0/0/45                 66*

Give a piece of code, want to extract ipaddress,macaddress,interface,vpninstance four data

Writes to the MySQL database, is multi-line,

>>>>insert into ip_interface (ipaddress,macaddress,interface,vpn) values ('192.168.66.11','0016-413e-0c62','GE0/0/23','66');*

Reply content:

PHP uses regular expressions to extract four of columns of data, and to bulk import data into MySQL database

>>>>[0601_Access_S5352]dis arp>>>>IP ADDRESS      MAC ADDRESS  EXPIRE(M) TYPE INTERFACE      VPN-INSTANCE>>>>-------------------------------------------------------------------------->>>>192.168.66.11   0016-413e-0c62         SF-  GE0/0/23                 66>>>>192.168.66.13   0019-b906-e2ec         S--  GE0/0/18                 66>>>>192.168.66.15   0019-b906-be56         S--  GE0/0/16                 66>>>>192.168.66.17   0018-8b1e-96df         SF-  GE0/0/45                 66*

Give a piece of code, want to extract ipaddress,macaddress,interface,vpninstance four data

Writes to the MySQL database, is multi-line,

>>>>insert into ip_interface (ipaddress,macaddress,interface,vpn) values ('192.168.66.11','0016-413e-0c62','GE0/0/23','66');*
  • 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.