正则表达式字符用于修改字符串的问题

huangapple go评论68阅读模式
英文:

Issue with Regex characters to modify a string

问题

以下是您要翻译的内容:

新手来到Stack Overflow。
尝试解决正则表达式以修改以下内容的问题:

原始字符串:

753108944)))","0"
"MULTIPOLYGON (((-7.7885889

期望的字符串:

753108944),(-7.7885889

我需要从字符串中删除 ))","0" & vbCrLf & "MULTIPOLYGON ((,但成功率非常低,我认为是因为其中包含了句点(.)。
已尝试许多正则表达式替换配置以及标准字符串操作方法,但均未成功。

英文:

New to Stack Overflow.
Having issues trying to resolve Regex expression to modify the below:

Original string:

 753108944)))","0" 
"MULTIPOLYGON (((-7.7885889

Desired string:

753108944),(-7.7885889

I need to remove the ))","0" & vbCrLf & "MULTIPOLYGON (( from the string and having a extremely poor success rate, and I think its due to the . (period) being in there.
Have tried many regex replace configurations as well as standard string manipulation methods with no success.

答案1

得分: 0

Replace会执行你在问题中描述的操作:

Dim originalString As String = "753108944)))","""0""" & vbCrLf & """MULTIPOLYGON (((-7.7885889"""
Dim processedString As String = originalString.Replace("))","""0""" & vbCrLf & """MULTIPOLYGON ((")
英文:

Replace will do what you are describing in your question:

Dim originalString As String = "753108944)))"",""0""" & vbCrLf & """MULTIPOLYGON (((-7.7885889"""
Dim processedString As String = originalString.Replace("))"",""0""" & vbCrLf & """MULTIPOLYGON ((", ",")

答案2

得分: 0

替换以下模式,使用 ")(".

(?s)\){3}.+\({3}

输出

 753108944),(-7.7885889
英文:

Find and replace the following pattern, with "),(".

(?s)\){3}.+\({3}

Output

 753108944),(-7.7885889

huangapple
  • 本文由 发表于 2023年6月15日 05:10:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76477560.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定