Hi all, like many I am transforming my covid time to coding. Coviding? :)
I need to extract substrings from a string with VBA in Excel, and would appreciate suggestions on the solutions available. I thought regex would be the way to go, but am actually quite uncertain as I am fairly unfamiliar with regex and this is perhaps to complicated for it. Perhaps there is some much more simple solution that I am unaware of, any suggestions very much appreciated.
The strings originate in the english language files of the open source mybb forum. I am creating an excel workbook to assist translators, which I will donate to their community.
What is needed is the html removed, and each substring placed in adjacent cells. The pattern is:
- before <
- between > and <
- text after >
Examples of the strings are (without first and last quotation mark):
Example 1:
"You are currently viewing a stripped down version of our content. <a href=\"{1}\">View the full version</a> with proper formatting."
- string 1 =
"You are currently viewing a stripped down version of our content. "
- string 2 =
"View the full version"
- string 3 =
" with proper formatting."
Example 2:
"<b>Private</b> Only you will be able to view this event. (Registered Users Only)."
- string 1 =
"Private"
- string 2 =
" Only you will be able to view this event. (Registered Users Only)."
Example 3:
" This day does not have any events associated with it.<p><a href=\'calendar.php?action=addevent&calendar={1}&day={2}&month={3}&year={4}\'>Post an Event</a>.</p>"
- string 1 =
"This day does not have any events associated with it."
- string 2 =
"Post an Event"
- string 3 =
"."
Example 4: (This example is the largest one I have seen)
"<p><br />[list]<br />[*]List Item #1<br />[*]List Item #2<br />[*]List Item #3<br />[/list]<br /><ul><li>List item #1</li><li>List item #2</li><li>List Item #3</li>"
- string 1 =
"[list]"
- string 2 =
"[*]List Item #1"
- string 3 =
"[*]List Item #2"
- string 4 =
"[*]List Item #3"
- string 5 =
"[/list]"
- string 6 =
"List item #1"
- string 7 =
"List item #2"
- string 8 =
"List item #3"
Any suggestions would be greatly appreciated.
Edit: Adding a few more samples
<span title=\"{1}\">Today</span>
<span title=\"{1}\">Yesterday</span>
<span title=\"{5}{6}\">{1}{2} {3} {4}</span>
You are currently using <strong>{1}</strong>.
<br /><br />You are encouraged to register; once you register you will be able to post messages, set your own preferences, and maintain a profile.
<br /><br />Some of the features that generally require registration are subscriptions, changing of styles, accessing of your Personal Notepad and emailing forum members.
<br /><br />Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk.
<br /><br />Cookies on this forum also track the specific topics you have read and when you last read them.
<p><br />[url]http://www.example.com/[/url]<br /> <a href=\"http://www.example.com/\">http://www.example.com/</a>
<p>[url=http://www.example.com/]Example.com[/url]<br /> <a href=\"http://www.example.com/\">Example.com</a>
<p>[email]example@example.com[/email]<br /> <a href=\"mailto:example@example.com\">example@example.com</a>