RegExp.Replace [英] RegExp.Replace

查看:65
本文介绍了RegExp.Replace的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用RegExp.Replace(字符串,字符串,字符串)删除一些部分

的大字符串。但我似乎无法让它匹配

所有字符直到并包括xxxxx (我认为这将是

"。* xxxxx"但它不起作用)。我可以让它更精确地匹配

段没问题,但不是所有字符直到并包括xxxxx

或xxxxx及其后的所有字符。 "任何想法?

问候,

David P. Donahue
dd ****** @ ccs.neu.edu
http: //www.cyber0ne.com

I''m using RegExp.Replace(string, string, string) to remove some pieces
of large strings. But I seem to be having trouble getting it to match
"all characters up to and including xxxxx" (which I thought would be
".*xxxxx" but it''s not working). I can get it to match more precise
segments no problem, but not "all characters up to and including xxxxx"
or "xxxxx and all characters after it." Any ideas?
Regards,
David P. Donahue
dd******@ccs.neu.edu
http://www.cyber0ne.com

推荐答案

" David P. Donahue"写道:
"David P. Donahue" wrote:

我正在使用RegExp.Replace(字符串,字符串,字符串)删除大字符串的一些部分。但我似乎无法让它匹配
所有字符直到并包括xxxxx (我认为这将是
。* xxxxx,但它不起作用)。我可以得到它以匹配更精确的
段没有问题,但不是所有字符直到并包括xxxxx
或xxxxx以及它之后的所有字符。任何想法?

I''m using RegExp.Replace(string, string, string) to remove some pieces
of large strings. But I seem to be having trouble getting it to match
"all characters up to and including xxxxx" (which I thought would be
".*xxxxx" but it''s not working). I can get it to match more precise
segments no problem, but not "all characters up to and including xxxxx"
or "xxxxx and all characters after it." Any ideas?




您可能需要单线选项才能强制执行。匹配\ n。


-

www.midnightbeach.com


值得一试,但每当我在

中指定单线模式时options(Replace(string,string,string,options))线程总是

超时。经过一段时间后,Web服务器只返回线程被中止

错误。


我想我也许可以使用String.Replace去除所有的运输

返回,因为我不在乎加载HTML代码的字符串是否全部

一行还是没有,但那不是''似乎也在工作。如果我使用

String.Replace(Char.ToString((Char)13),"它没有替换,但它确实匹配,因为它是b / b如果我使用非空字符串,则在每个

回车时添加它。


任何想法?

问候,

David P. Donahue
dd******@ccs.neu.edu
http://www.cyber0ne.com
Jon Shemitz写道:
It was worth a try, but whenever I specify Singleline mode in the
options ("Replace(string, string, string, options)") the thread always
times out. The web server just returns a "thread was being aborted"
error after a bit of time passes.

I figured maybe I can use String.Replace to strip out all the carriage
returns, since I don''t care if the string loaded with HTML code is all
one line or not, but that doesn''t seem to be working either. If I use
String.Replace(Char.ToString((Char)13), "") it doesn''t replace, but it
does match because if I use a non-empty string it adds it at each
carriage return.

Any ideas?
Regards,
David P. Donahue
dd******@ccs.neu.edu
http://www.cyber0ne.com
Jon Shemitz wrote:
" David P. Donahue"写道:
"David P. Donahue" wrote:
我正在使用RegExp.Replace(字符串,字符串,字符串)删除大字符串的一些部分。但我似乎无法让它匹配
所有字符直到并包括xxxxx (我认为这将是
。* xxxxx,但它不起作用)。我可以得到它以匹配更精确的
段没有问题,但不是所有字符直到并包括xxxxx
或xxxxx以及它之后的所有字符。任何想法?
I''m using RegExp.Replace(string, string, string) to remove some pieces
of large strings. But I seem to be having trouble getting it to match
"all characters up to and including xxxxx" (which I thought would be
".*xxxxx" but it''s not working). I can get it to match more precise
segments no problem, but not "all characters up to and including xxxxx"
or "xxxxx and all characters after it." Any ideas?



你可能需要单线选项来强迫。匹配\ n。


You probably need the Singleline option, to force . to match \n.



" David P. Donahue"写道:
"David P. Donahue" wrote:
值得一试,但每当我在
选项中指定单线模式(替换(字符串,字符串,字符串,选项))时,线程总是
超时。经过一段时间后,Web服务器只返回正在中止的线程错误。
It was worth a try, but whenever I specify Singleline mode in the
options ("Replace(string, string, string, options)") the thread always
times out. The web server just returns a "thread was being aborted"
error after a bit of time passes.




你究竟用什么作为一个正则表达式模式?



What, exactly, are you using as a Regex pattern?

我正在使用RegExp.Replace(字符串,字符串,字符串)删除一些部分
大字符串。但我似乎无法让它匹配
所有字符直到并包括xxxxx (我认为这将是
。* xxxxx,但它不起作用)。我可以得到它以匹配更精确的
段没有问题,但不是所有字符直到并包括xxxxx
或xxxxx以及它之后的所有字符。任何想法?
I''m using RegExp.Replace(string, string, string) to remove some pieces
of large strings. But I seem to be having trouble getting it to match
"all characters up to and including xxxxx" (which I thought would be
".*xxxxx" but it''s not working). I can get it to match more precise
segments no problem, but not "all characters up to and including xxxxx"
or "xxxxx and all characters after it." Any ideas?



你可能需要单线选项来强迫。匹配\ n。


You probably need the Singleline option, to force . to match \n.




-

www.midnightbeach.com


这篇关于RegExp.Replace的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆