vergenoeg
asked on
RegExp Replace expression for paragraph numbering
I am using "Microsoft VBScript Regular Expressions 5.5"
I want to remove all paragraph numbering in a text document (string).
So what must the Replace Regular Expression be to replace all occurrences of "n.", "n.n", "nn.nn" and ".n" with a Null string? (Where n is a digit from 0-9)
I want to remove all paragraph numbering in a text document (string).
So what must the Replace Regular Expression be to replace all occurrences of "n.", "n.n", "nn.nn" and ".n" with a Null string? (Where n is a digit from 0-9)
@"((?[0-9]+)?\.[0-9]+|[0-9 ]+\.)"
ASKER
ahoffmann,
I have a string "myString" which contains thousands of characters including paragraph numberings like "1.", "1.1", etc.
My code:
Public Sub ReplaceNow()
Dim objRegExp As RegExp
Set objRegExp = New RegExp
strReplace = ""
strPattern = "((?[0-9]+)?\.[0-9]+|[0-9] +\.)"
objRegExp.IgnoreCase = True
objRegExp.Global = True
strToReplace = GetText("c:\MyText.txt")
objRegExp.Pattern = strPattern
If (objRegExp.test(myString) = True) Then ' <== fails here
strResult = objRegExp.Replace(strToRep lace, strReplace)
End If
Debug.Print (strResult)
End Sub
And then it fails on this statement:
If (objRegExp.test(myString) = True) Then
which means it could not find a match
I have a string "myString" which contains thousands of characters including paragraph numberings like "1.", "1.1", etc.
My code:
Public Sub ReplaceNow()
Dim objRegExp As RegExp
Set objRegExp = New RegExp
strReplace = ""
strPattern = "((?[0-9]+)?\.[0-9]+|[0-9]
objRegExp.IgnoreCase = True
objRegExp.Global = True
strToReplace = GetText("c:\MyText.txt")
objRegExp.Pattern = strPattern
If (objRegExp.test(myString) = True) Then ' <== fails here
strResult = objRegExp.Replace(strToRep
End If
Debug.Print (strResult)
End Sub
And then it fails on this statement:
If (objRegExp.test(myString) = True) Then
which means it could not find a match
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks very much, it works perfectly.
ASKER
Thanks very much, it works perfectly.
glad to have helped you (as I never touched any M$ tools:)
good luck
good luck
(with sed you need to add escapes sed 's/[0-9]\+\.[0-9]\+\|\.[0-