Solved

Get an array of strings from text

Posted on 2013-10-31
2
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

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…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

627 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