将Perl Regex表达式转换为Python

时间:2022-07-03 12:15:56

I'm trying to figure out the equivalent Python code for this Perl expression:

我正在试图找出这个Perl表达式的等效Python代码:

$pc =~ s/[[:^alnum:]]*//g;

Thanks!

谢谢!

1 个解决方案

#1


1  

The regular expression means: remove all non-alphanumeric characters:

正则表达式表示:删除所有非字母数字字符:

pc = re.sub('\W','', pc)

#1


1  

The regular expression means: remove all non-alphanumeric characters:

正则表达式表示:删除所有非字母数字字符:

pc = re.sub('\W','', pc)