Solved

Get an array of strings from text

Posted on 2013-10-31
2
229 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
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…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

920 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

17 Experts available now in Live!

Get 1:1 Help Now