[Gambas-user] Regular expression searching

Ian Haywood ihaywood at ...1979...
Wed Apr 3 10:11:56 CEST 2013


I have often missed in Gambas the ability to search through strings
using a regular expression and
provide a function to create replacements
Gambas doesn't have procedural pointers or closures, so it's
impossible to do it like in ruby/python/etc, but I've found the same
can be achieved using an iterator

IN the hope it is useful for others this is my module CRegex.

Here's an example, it turns the HTML tag """ into alternating
opening (``) and closing ('') quotes as required by the LaTeX system

  r = New CRegex(""", s, Regexp.Caseless)
   flag = False
   For Each r
      If flag Then
         flag = False
         r.Set("''") ' close quotes in LaTeX
      Else
         flag = True
         r.Set("``") ' open quotes
      Endif
   Next
   s = r.Subject
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cRegex.class
Type: application/octet-stream
Size: 3339 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20130403/9539f722/attachment.obj>


More information about the User mailing list