Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 正则表达式来删除一些特殊字符_Regex_Actionscript 3 - Fatal编程技术网

Regex 正则表达式来删除一些特殊字符

Regex 正则表达式来删除一些特殊字符,regex,actionscript-3,Regex,Actionscript 3,我正在寻找一个正则表达式,它可以从字符串(以及空格)中删除以下所有字符: ~%&\;:“,?# 你能帮我吗?我正在用ActionScript 3编写代码。使用perl删除$mystring中的所有空白,你需要添加其他字符才能创建正则表达式 $mystring = "..."; $mystring =~ s/\s//g; [~%&\\\;:“,?#\s]+ 在ActionScript中 yourString.replace(/[~%&\\;:"',<>?#\s]/g,"");

我正在寻找一个正则表达式,它可以从字符串(以及空格)中删除以下所有字符:

~%&\;:“,<>?#


你能帮我吗?我正在用ActionScript 3编写代码。

使用perl删除
$mystring
中的所有空白,你需要添加其他字符才能创建正则表达式

$mystring = "...";
$mystring =~ s/\s//g;
[~%&\\\;:“,?#\s]+

在ActionScript中

yourString.replace(/[~%&\\;:"',<>?#\s]/g,"");
yourString.replace(/[~%&\\\;:“,?#\s]/g,”;
在Perl中也是如此:

$_ = "~ % & \\ ; : \" ' , < > ? #";
s/[~%&\\;:"',<>?#\s]//g;
print; #prints nothing
$\”~%&\\;:\" ' , < > ? #";
s/[~%&\\\;:“,?#\s]//g;
打印;#不打印任何内容

你能指定你使用的语言吗?哦,当然,对不起:我在使用ActionScript 3你怎么知道OP使用perl的?这只是所需解决方案的1/14。几乎是否决票。单引号和双引号不需要转义,至少在perl中是这样。@Quick,removed escapes,我在bash上尝试使用sed。这很公平,因为P既没有表示语言也没有表示环境。:)您好,谢谢,我注意到如果不在end@Lotts,是的,如果需要替换所有实例,全局标志将需要它。将re导入为open('txt.txt',r')作为fi:tm=fi.read()。将(',','\n',)替换为open('out_3.txt','w'),作为z:for j in tm:y=re.sub('[0-9{}-,:\u\.=+\ 124;\/],'\ n',j)对于y:z中的gn.write(gn)我曾试图帮助一些人格式化,但请检查它,您可以使用4个空格格式化代码,并使用“格式化行内代码。请不要在注释中留下代码。StackOverflow不需要完美的英语(否则我自己会很迷路).但是你并不是真的不能做得更好,是吗?一些大写字母,少量标点符号,更多的英语单词,这些都会让这篇文章更好。请?
$_ = "~ % & \\ ; : \" ' , < > ? #";
s/[~%&\\;:"',<>?#\s]//g;
print; #prints nothing
import re 
with open ('txt.txt', 'r') as fi: # to read ur file 
    tm = fi.read().replace(',', '\n,') # to replace " , " with \n{enter} i.e to new line
    with open ('out_3.txt','w') as z: # to crate new file wher all changes will done or we simply say that to write a new file 
        for j in tm:
            y = re.sub("[0-9 {} <> -,: _\. = +| \/]",'\n' , j)# to remove required 
for gn in y:
    z.write(gn)