I'm not too familiar with VB script and am having trouble with the syntax for the pattern property of my regexp object.
I have some data that looks like this:
Front SHD Trip CLEAR OBSTRUCTION BEFORE CONTINUING [Table Position = 0mmFwd] Front SHD Trip CLEAR OBSTRUCTION BEFORE CONTINUING [Table Position = 563mmFwd]
I want to strip off the [Table Position = x] part from these records so I have created a little function. Although there are no errors, it's not stripping off the end of the string as expected and I'm fairly sure that the issue is my syntax in this line:
objRegExp.Pattern = "[*]"
Here's the whole function:
Function RemoveTablePosition(AlarmText)
'Initialise a new RegExp object
Dim objRegExp, strNewAlarmText
Set objRegExp = New Regexp
'Set the RegExp object's parameters
objRegExp.IgnoreCase = True
objRegExp.Global = True
'Look for [Table Position = xx] at the end of the code text (they always follow the same format)
objRegExp.Pattern = "[*]"
'Replace all [Table Position = xx] with the empty string to effectively remove them
strNewAlarmText = objRegExp.Replace(AlarmText, "")
'Return the new alarm text value
RemoveTablePosition = strNewAlarmText
Set objRegExp = Nothing
End Function
Can someone point me in the right direction? Thanks in advance!
\[[^\][]*]or\[[^\][]*]$($- end of string/line) - Wiktor Stribiżew