我有一个字符串,其中包含以前由WP格式化的内容,它包含几种类型的[caption]
标记。例子:
[标题(此处为属性)]一些文字[/ caption]
[标题(此处为属性)]©姓名和姓氏[/ caption]
[caption id =“attachment_49532”align =“aligncenter”width =“530”] [/ caption]
我只需删除包含©
后跟人名的内容。
我试过了:
preg_replace("/\[caption(.*?)\]©(.*?)\[\/caption\]/","",$string);
但只有当输入字符串我只有一个[caption]标签(如
)时才能完成工作$string = "[caption (parameters here)]©name and surname[/caption]";
而不是里面有更多元素的字符串。
我做错了什么?
答案 0 :(得分:0)
启用DOTALL修饰符,以便在正则表达式中创建点以匹配换行符。
for row in reader:
# Note you need this indented under your for loop to access each "gender" value in each row
if row['gender'] == 1:
Men += 1
else: # could also use "elif row['gender'] == 2:" and catch any unexpected values with "else"
Women += 1