简体   繁体   English

从文本中删除某些特殊字符

[英]remove certain special characters from Text

Hey guys I am making a project on PhantomJS where I read source code of some webpages and i extract some info i need from there. 大家好,我正在PhantomJS上做一个项目,在其中阅读了一些网页的源代码,并从中提取了一些我需要的信息。 I successfully finished the work just one issue I am facing right now. 我成功完成了工作,只是我现在面临的一个问题。 I have a text that have inside it special characters I need to get rid off. 我有一个文本,里面有特殊字符,我需要摆脱这些特殊字符。 in my case I have : 就我而言:

Avenue de Citeaux 22<br><br>1348 Louvain-la-Neuve

that "<><>" i need to get rid off, I am using : 我需要摆脱的“ <> <>”,我正在使用:

str.replace('<br><br>','')

but its not working ... any ideas ? 但是它不起作用...有什么想法吗?

尝试str.replace(/<br>/g, "") (启用了全局搜索标志的正则表达式,以替换所有出现的情况)。

something like this? 这样的东西?

str = str.replace(/(<([^>]+)>)/ig,"");

I've just realised, str.replace() RETURNS the value, not replaces it. 我刚刚意识到,str.replace()返回值,而不是替换它。 Try the above. 尝试以上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM