find find asterisks in a string

Sasha42
Sasha42 used Ask the Experts™
on
I am pulling the body of out of an Outlook message.  There are two rows of asterisks and I need to pull the text between the two rows.

There are various lines of text above the asterisks.  The text between the asterisks will have various lines too. Thanks so much!

'**********************
Reason for denial:
'**********************
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Will there be asterisks anywhere else in the message text?
Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010

Commented:
Will there always be the same number of asterisks?

Is this the only text in the body?

You might be able to use the Split() function to parse the text on the vbcrlf character

myText = Split(strBody, vbcrlf)

Then loop through the myText array looking for the asterisks, then concatenate the array elements between the "'***********" strings, or you could use the Replace function, something like:

myText = Replace(strBody, "*", "")

Author

Commented:
I could look for the word "denial:" and then I would need to pull the text until it gets to second line of astrisks.  Yes, the two lines of asterisks will be the only ones in the emai.
11/26 Forrester Webinar: Savings for Enterprise

How can your organization benefit from savings just by replacing your legacy backup solutions with Acronis' #CyberProtection? Join Forrester's Joe Branca and Ryan Davis from Acronis live as they explain how you can too.

Owner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010
Commented:
That would work, but given your other answer, I think I would use:

strDenialReason = Split(Replace(Replace(strBody,"'*", "" )"*", ""), ":")(1)

What this would do is strip out the apostrophe/asterisk combination '* from the start of each of the rows containing the asterisks.  It would then strip out all of the asterisks.  Then, it would split what remains at the colon ":", and return only the string that follows the colon.

Give that a try and see how it works.

Author

Commented:
That is totally awesome! Very elegant! Works like a charm. Thanks!!
Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010

Commented:
glad I could help.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial