• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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