Solved

Get an array of strings from text

Posted on 2013-10-31
2
228 Views
Last Modified: 2013-10-31
I need to retrieve all values between @p_ and space from a string into an array in VBA.

For example, from this string:
"<willbe name=""Current24' value='if(g_movsum(loan_nid;;;current_flag;24;@p_lag )=24;1;0)'/> <willbe name=@p_name value=@p_value *(Current12)'/>"
I need an array with: @p_lag, @p_name, @p_value
0
Comment
Question by:leonstryker
2 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 39614392
Perhaps:

Function GetPdata(strIn As String)
   Dim matches
   Dim asOut() As String
   Dim n As Long
   
   With CreateObject("vbscript.regexp")
      .Pattern = "(@p_[^ ]+)"
      .Global = True
      If .test(strIn) Then
      Set matches = .Execute(strIn)
      ReDim asOut(matches.Count - 1)
      For n = 0 To matches.Count - 1
         asOut(n) = matches(n)
      Next n
         GetPdata = asOut
      Else
         GetPdata = ""
      End If
   End With

End Function

Open in new window

0
 
LVL 29

Author Closing Comment

by:leonstryker
ID: 39614410
Perfect, thank you for your help.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now