Regex 如何使用正则表达式删除未知数量的换行符

Regex 如何使用正则表达式删除未知数量的换行符,regex,vbscript,Regex,Vbscript,我有这样的文本 (57) some text some other text unknown nubmer of such lines (12) some text 我想把它减少到 (57) some text some other text unknown nubmer of such lines (12) some text 表示空间分隔,而不是换行 是否可以使用regex find and replace,或者我需要编写一个脚本 我可以使用:\(\d{1,2}\)([\w\w]*?)\

我有这样的文本

(57) some text
some other text
unknown nubmer of such lines
(12) some text
我想把它减少到

(57) some text some other text unknown nubmer of such lines
(12) some text
表示空间分隔,而不是换行

是否可以使用regex find and replace,或者我需要编写一个脚本

我可以使用:
\(\d{1,2}\)([\w\w]*?)\(\d{1,2}\)

事实证明,我的数据不一致,需要定义开始和结束


您似乎需要基于正则表达式的替换。使用

[\r\n]+(?!\(\d+\))
并替换为一个空格。此表达式将匹配所有未后跟
+数字+
的换行符

结果:

(57) some text some other text unknown nubmer of such lines 
(12) some text 
(54) sometext some Text unknown nubmer of such lines 
(51) some text 
(86) some text some Text some other text 
(87) some text

这正是我问题的答案。但事实证明我的问题比我想象的更严重。谢谢你的建议。这将非常有帮助。那些不需要后期绑定的人,
RegExp
内置在VBScript中,只需使用
Set regEx=new RegExp
。如何使用
RegExp
Replace()
方法的示例-这个问题已经被许多人回答了很多次。感谢您指出。让我看看这是否是重复的。我不是说这个例子是重复的,只是这个问题已经被问了很多次,然后再看看所有的结果。
(57) some text some other text unknown nubmer of such lines 
(12) some text 
(54) sometext some Text unknown nubmer of such lines 
(51) some text 
(86) some text some Text some other text 
(87) some text