New topic: 

RegEx

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

       Page 1 of 1
   [ 5 posts ]                 Previous topic | Next topic         Author  
Message       henri           Post subject: RegExPosted: Thu Dec 03, 2009 2:41 
am                        
Joined: Thu Sep 04, 2008 11:29 am
Posts: 76              I maybe a silly question
Using the RegEx searching for a word is nice . would there be a way to copie 
the entire line were the word is in. Just the line not the  enitre sentence.
regards,
Henri   
                            Top                timhare           Post subject: 
Re: RegExPosted: Thu Dec 03, 2009 3:26 am                        
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 6882
Location: Portland, OR  USA              RegEx has begin of line and end of 
line markers.  So, yes, you can do it.   
                            Top               henri           Post subject: Re: 
RegExPosted: Thu Dec 03, 2009 8:26 am                        
Joined: Thu Sep 04, 2008 11:29 am
Posts: 76              Thanks Tim,
I,ve been looking around a bit. U mean wildcards? If so how do I implement that 
in the code?
code:
  dim rg as new RegEx
  dim mymatch as RegExMatch
  
  rg.SearchPattern= textin.Text
  mymatch=rg.Search(TextArea1.Text)
  
  if mymatch<> nil then
  textout1.Text= mymatch.SubExpressionString(0)
  
  else
  textout1.Text="text not found !"
  end if

thanks,
Henri   
                            Top                Karig           Post subject: 
Re: RegExPosted: Thu Dec 03, 2009 9:25 am                        
Joined: Tue Dec 23, 2008 6:08 am
Posts: 22              To match the whole line, I think you'd do something like 
this:

Dim t as String
t = Trim(textin.Text)
If Left(t, 1) <> "^" Then t = "^.*" + t
If Right(t, 1) <> "$" Then t = t + ".*$"
rg.SearchPattern = t

The "^" forces a match at the start of a line; the "$" forces a match at the 
end of the line; the ".*" (dot and asterisk) matches all text between the start 
or end of the line and the pattern you specified in textin.Text.

(I don't have RB handy and can't test this to be 100% sure it works, so try it 
out first before relying on it.)   
                            Top                henri           Post subject: 
Re: RegExPosted: Thu Dec 03, 2009 9:32 am                        
Joined: Thu Sep 04, 2008 11:29 am
Posts: 76              Thanks,
i'll def try it and let U know if it works.
THNX,
henri   
                            Top            Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 5 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