Parsing a String

E

Efialtis

I have a little complication to work through using VBA to parse out a
section of a string...
What I am in need of help with is the following line of TEXT...

"""<TD onmouseover=""""""""startOver(this, 'check38')""""""""
onclick=""""""""javascript:window.location='task.do?tab=workspace&amp;taskType=/zions/commercial/category/enterData/EnterBorrowerData&amp;taskInstance=6CCBFDA8-90C8-AE1B-5057-E38984ED0B35&amp;capsuleInit=loadTask&amp;needsCheckOut=true'""""""""
onmouseout=""""""""startOut(this, 'check38')""""""""
bgColor=#ffffff><SPAN class=TaskStart>Start Task</SPAN></TD>"""

This is already parsed out of a very large text, so I have narrowed it
down to this point.

The only thing I need in this whole mess is

task.do?tab=workspace&amp;taskType=/zions/commercial/category/enterData/EnterBorrowerData&amp;taskInstance=6CCBFDA8-90C8-AE1B-5057-E38984ED0B35&amp;capsuleInit=loadTask&amp;needsCheckOut=true

In PERL I would SPLIT this on "onclick", then split it again on the
FIRST instance of Single Quote. In both cases, I take the "Right
Side" of the split.
Then I split it again on the next FIRST instance of Single Quote, and
take the "LEFT Side", which would give me the string I want.

I have no idea how to do this in VBA...

This has to be somewhat dynamic, I cannot lock myself into taking X
characters after some string or character...each QUID might be the
same length, but the name sequence is NOT the same length...

I thought about using Trim$, but how do I trim up to some
point(deleting the unnecessary) and trim from a point to the end
(deleting the unnecessary) leaving me with the string I want...???
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Efialtis > écrivait :
In this message, < Efialtis > wrote:

|| I have a little complication to work through using VBA to parse out a
|| section of a string...
|| What I am in need of help with is the following line of TEXT...
||
|| """<TD onmouseover=""""""""startOver(this, 'check38')""""""""
||
onclick=""""""""javascript:window.location='task.do?tab=workspace&amp;taskTy
pe=/zions/commercial/category/enterData/EnterBorrowerData&amp;taskInstance=6
CCBFDA8-90C8-AE1B-5057-E38984ED0B35&amp;capsuleInit=loadTask&amp;needsCheckO
ut=true'""""""""
|| onmouseout=""""""""startOut(this, 'check38')""""""""
|| bgColor=#ffffff><SPAN class=TaskStart>Start Task</SPAN></TD>"""
||
|| This is already parsed out of a very large text, so I have narrowed it
|| down to this point.
||
|| The only thing I need in this whole mess is
||
||
task.do?tab=workspace&amp;taskType=/zions/commercial/category/enterData/Ente
rBorrowerData&amp;taskInstance=6CCBFDA8-90C8-AE1B-5057-E38984ED0B35&amp;caps
uleInit=loadTask&amp;needsCheckOut=true
||
|| In PERL I would SPLIT this on "onclick", then split it again on the
|| FIRST instance of Single Quote. In both cases, I take the "Right
|| Side" of the split.
|| Then I split it again on the next FIRST instance of Single Quote, and
|| take the "LEFT Side", which would give me the string I want.
||
|| I have no idea how to do this in VBA...
||
|| This has to be somewhat dynamic, I cannot lock myself into taking X
|| characters after some string or character...each QUID might be the
|| same length, but the name sequence is NOT the same length...
||
|| I thought about using Trim$, but how do I trim up to some
|| point(deleting the unnecessary) and trim from a point to the end
|| (deleting the unnecessary) leaving me with the string I want...???

SPLIT is a function available from VBA.
If you are certain that the string to parse has only one "onclick" (or that
the part you want is al;ways after the first "onclick") and the string you
want is always after the first single quote following the "onclick", then
the following should do the trick (I put your mess of string in a document,
at the beginning, i.e. the first paragraph):

'_______________________________________
Sub SplitMessyString()

Dim ToSplit As Range
Dim FinalString As String
Dim Splitting As Variant

Set ToSplit = ActiveDocument.Paragraphs(1).Range
ToSplit.MoveEnd wdCharacter, -1 'to remove the ¶
'at the end

Splitting = Split(ToSplit.Text, "onclick")
Splitting = Split(Splitting(1), "'")

FinalString = Splitting(1)
ActiveDocument.Range.InsertAfter Chr(13) & FinalString

End Sub
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
Top