This method returns an instance of the RegExMatch class if a match is found, or Nil if no match is found. To check if a regular expression matches a particular string, call the Search method of the RegEx object, and pass the subject string as a parameter. You can set various options in the Options property, which is an instance of the RegExOptions class. Assign your regular expression to the SearchPattern property. To use a regular expression, you need to create a new instance of the RegEx class. You’ll also need to use the TextConverter to convert the strings returned by the RegEx class from UTF-8 back into the encoding your application is working with.
This means that if you want to process non-ASCII data that you’ve retrieved from a file or the network, you’ll need to use Xojo’s TextConverter class to convert your strings into UTF-8 before passing them to the RegEx object. In PCRE, they’re off by default, while in Xojo they’re on by default. The only exception are the case insensitive and “multi-line” matching modes. Everything said in the tutorial about PCRE’s regex flavor also applies to Xojo. The regular expressions tutorial on this website does not explicitly mention Xojo. What this means to you as a Xojo developer is that the RegEx class provides you with a rich flavor of Perl-compatible regular expressions. Internally, this class is based on the open source PCRE library. Xojo, formerly known as REALbasic, includes a built-in RegEx class.
#Xojo program code how to#
How to Use Regular Expressions in Xojo (REALbasic)