如果您假设单引号前面或后面始终有空格,则以下一对正则表达式应该有效:
$line =~ s/\s'/ /g; #preceded by whitespace
$line =~ s/'\s/ /g; #followed by whitespace
Run Code Online (Sandbox Code Playgroud)
您还需要考虑字符串是否以单引号开头或结尾:
$str =~ s/^'//; #at the start of a string
$str =~ s/'$//; #at the end of a string
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1927 次 |
| 最近记录: |