如何使用正则表达式去掉被双引号包裹的数字两边的双引号

WBOY
Release: 2016-06-06 20:37:45
Original
2119 people have browsed it

从某云导出数据库表为CSV格式,发现bigint字段两边也被加上了双引号,不应该啊不应该,如何去掉呢?

示例记录:

<code>"31189","aaaa","$P$BFMnptFob/7bmU2o***PNqorSMKzLs0","aaaa","aaa@qq.com","","2015-02-27 02:18:54","","0","oo","0000-00-00"

"31191","bbbb","$P$BeRmQEYPfnOfKrKpF***9osOe3v0aq/","bbb","bbb@qq.com","","2015-02-27 04:23:52","","0","bbb","0000-00-00"</code>
Copy after login
Copy after login

回复内容:

从某云导出数据库表为CSV格式,发现bigint字段两边也被加上了双引号,不应该啊不应该,如何去掉呢?

示例记录:

<code>"31189","aaaa","$P$BFMnptFob/7bmU2o***PNqorSMKzLs0","aaaa","aaa@qq.com","","2015-02-27 02:18:54","","0","oo","0000-00-00"

"31191","bbbb","$P$BeRmQEYPfnOfKrKpF***9osOe3v0aq/","bbb","bbb@qq.com","","2015-02-27 04:23:52","","0","bbb","0000-00-00"</code>
Copy after login
Copy after login

为啥要去掉php 有对应函数
http://php.net/str_getcsv

昂,已经弄了个php版本的处理了

function fucking_aliyun_rds($line){

<code>    if(!$line) return;
    $line=(string)$line;

    $pattern='/^\"\d{1,5}\"/';
    $int=$replacement=false;
    if(preg_match($pattern, $line, $matches)){

        $int=(int)str_replace('"', '', $matches[0]);
    }else{
        return $line;
    }

    if($int){
        $replacement = $int;
        $line=preg_replace('""', '',$line);
        $b=preg_replace($pattern, $replacement, $line);

    }
    $b.="\t";
    return $b;
</code>
Copy after login

}

$f = fopen ("wp_users.txt", "r");
$ln= 0;
while (! feof ($f)) {
$line= fgets ($f);
/* ++$ln;/
/
printf ( $ln);*/
if ($line===FALSE) {
}
else{

<code>    $a=fucking_aliyun_rds($line);
    echo $a;


}
</code>
Copy after login

}
fclose ($f);

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!