我有这样的文字
要使用代码删除|<?php
header("Content-type: application/json; charset=utf-8");
$response = array();
if($_SERVER['REQUEST_METHOD'] == 'GET'){
$user = $_GET['par1'];
$passwd = sha1($_GET['par2']);
$consulta = "SELECT * FROM USUARIOS WHERE USUARIOS.usuarios_nombreusuario = '$user' AND USUARIOS.usuarios_password = '$passwd' LIMIT 1";
$proceso = mysqli_query($conexioni, $consulta) or die(mysqli_error($conexioni));
$cols = mysqli_num_rows($proceso);
if($cols == 0){
$response['login'] = "false";
} else{
$response['login'] = "true";
}
echo json_encode($response);
}
?>
<<.*>>
尽管将标志设置为re.multiline,#+begin_src ipython :session apue :results output
import re
fp = open("01.org", "r+")
text = fp.read()
re.sub(r"<<.*>>", "", text, flags=re.MULTILINE)
print(text[:50])
# fp.write(text)
#+end_src
#+RESULTS:
: ** <<page_1>>1. UNIX System Overview
: :PROPERTIE
的第一行没有被删除?
我的用法有什么问题?
答案 0 :(得分:1)
正则表达式似乎还可以,您忘记为文本变量分配新值了:
import re
text = "<<page_1>>1. UNIX System Overview"
text = re.sub(r"<<.*>>", "", text, flags = re.MULTILINE)
print(text[:50])