• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 303
  • Last Modified:

extract a substring

I' am trying to extract a substring from and exception message.

e.g from the following error message
 
Error: Previous READ must be same dial format as  CURRENT read ***TRACE***  SourceProc:spRead_Basic_Create SourceLine:160 CallingProc:spRead_Basic_Create Args:@NMI=3114563410, @Meter=699317, @Reg=17, @UOM=KWH, @NMISuffix=11, @MarketStream=11, @previousRead=113184, @previousReadDate=Aug 16 2009 12:00AM, @CurrRead=11334.9, @CurrReadDate=Aug 19 2009 12:00AM, @noErrorCheck=0,  Error: Previous READ must be same dial format as  CURRENT read ***TRACE***  SourceProc:spRead_Basic_Create SourceLine:160 CallingProc:spRead_Basic_Create Args:@NMI=3114563410, @Meter=699317, @Reg=17, @UOM=KWH, @NMISuffix=11, @MarketStream=11, @previousRead=113184, @previousReadDate=Aug 16 2009 12:00AM, @CurrRead=11334.9, @CurrReadDate=Aug 19 2009 12:00AM, @noErrorCheck=0,

I need to extract the all insances of the  substring where I have "Error: (the error message) "

how do I do it?
0
manivineet
Asked:
manivineet
1 Solution
 
AnilKumarSharmaCommented:
This can be done something like below (pseudocode) . Note that you have to refine it.

Dim MyString As String
Dim tempString As String
Dim startPos As Integer
Dim endPos As Integer
Dim charCount As Integer

MyString = "The whole error string is here like Error: (the error message) ***TRACE***   Error: (the error message) ***TRACE***  "

startPos=  InStrRev(MyString, "Error:")
endPos  =  InStrRev(MyString "***TRACE***")
set tempString = MyString
While(startPos)
{
   charCount = endPos  - startPos +1
   Print Mid$(tempString,startPos,charCount)}
   startPos=  InStrRev(tempString , "Error:")
   tempString = Right$(tempString ,startPos)
   startPos=  InStrRev(tempString , "Error:")
   endPos  =  InStrRev(MyString "***TRACE***")
}
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now