New topic: 

Array / String Questions

<http://forums.realsoftware.com/viewtopic.php?t=47398>

         Page 1 of 1
   [ 3 posts ]                 Previous topic | Next topic          Author  
Message        mikecotrone          Post subject: Array / String 
QuestionsPosted: Mon Mar 25, 2013 11:06 am                         
Joined: Tue Mar 05, 2013 2:33 pm
Posts: 19                I am working on a part of my code and I am having a 
newbie issue.

My goal is to perform my RegEx search and populate my Array. Right now I am 
populating a string using matchtext = match.SubExpressionString(0) which works.

However I want to directly populate an array so I can capture each 
subexpression string match through a loop and record it in the Array Element + 
1. When I try the following code i get an OutofBoundException whenever the 
match is called.

FWIW this is a Module that has a bunch of Properties declaring variables etc.


sub FindRegExText(Target As String, SearchString as String)
  
  Regexm = New RegEx
  
  // Use the User Input to Search for a String
  regexm.options.caseSensitive = true
  regexm.SearchPattern = SearchString
  
  // Set the Regular Expression Target
  match = regexm.Search(Target)
  
  // Set the search process
  if match <> nil then
  
  matchtext = match.SubExpressionString(0)
  
  MatchedSearch(counter) = matchtext
  
  // Show Match Results Status in the Debug Window
  Debugging.TextArea1.AppendText "Matched Text: " + MatchedSearch(counter) + 
EndOfLine + EndOfLine
  else
  // Show No Match Found Status in the Debug Window
  Debugging.TextArea1.AppendText "No Match Found!" + EndOfLine + EndOfLine
  end if
end sub


The above code is called by the following Method which controls the looping etc.

Sub SearchData
  // Display the entire File that has Populated the FileByLineArray (Non RegEx 
Parsed)
  for counter = 0 to UBound(FileByLineArray)
  Window1.Listbox1.AddRow FileByLineArray(Counter)
  next
  
  
  // Search for RegEx String using the FileByLineArray as the Source
  For counter = 0 to UBound(FileByLineArray) - 1
  Debugging.TextArea1.AppendText "Line #" + str(counter) + EndOfLine
  FindRegExText(FileByLineArray(counter),"(?<=\bID[:]\s)(\w+).*")
  
  next
end sub


Any ideas to point me in the right direction would be much appreciated     
_________________
Mike Cotrone - CCIE #8411 R&S, CCIE #8411 Voice
Chief Technology Officer 
Onepath Systems, LLC

Real Studio 2012 Mac OS, Windows, Ubuntu Linux  
                             Top                timhare          Post subject: 
Re: Array / String QuestionsPosted: Mon Mar 25, 2013 11:12 am                   
      
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12174
Location: Portland, OR  USA                Use:

MatchedSearch.Append matchtext   
                             Top                mikecotrone          Post 
subject: Re: Array / String QuestionsPosted: Mon Mar 25, 2013 11:27 am          
               
Joined: Tue Mar 05, 2013 2:33 pm
Posts: 19                timhare wrote:Use:

MatchedSearch.Append matchtext


Thank you Tim. Exactly what I needed... I have to get used to that style of 
thinking     
_________________
Mike Cotrone - CCIE #8411 R&S, CCIE #8411 Voice
Chief Technology Officer 
Onepath Systems, LLC

Real Studio 2012 Mac OS, Windows, Ubuntu Linux  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 3 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to