Solved

Get an array of strings from text

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

710 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