Article Preview
Buy Now
COLUMN
Regular Expressions with Xojo
The MBS Plugins has its own RegEx library
Issue: 20.6 (November/December 2022)
Author: Stefanie Juchmes
Author Bio: Stefanie studied computer science at the university in Bonn. She came in touch with Xojo due to the work of her brother-in-law and got a junior developer position in early 2019 at Monkeybread Software.
Article Description: No description available.
Article Length (in bytes): 14,211
Starting Page Number: 65
Article Number: 20608
Resource File(s):
project 20608.zip Updated: 2022-10-31 22:45:03
Related Link(s): None
Excerpt of article text...
Say you want to search for email addresses in some text and extract only these addresses from the text. Or you want to replace all internet addresses with a new internet address of your own. In these cases, regular expressions are a good solution.
What regular expressions are and how you can use them in Xojo with the MBS Xojo plugins I will show you in this article. The MBS Xojo plugin uses the PCRE 2 (Perl Compatible Regular Expressions) C-library. This provides us an engine with which we can work with regular expressions.
What are regular expressions?
With regular expressions you can search for certain patterns in some text or check a string to see if it meets certain criteria. e.g. if the chosen password contains upper and lower case letters, at least one number, one special character, and is at least eight characters long.
If we search for something in a text search then we actually are always searching for a regular expression. For example, if we enter the word
Miss
, then we are really searching for a pattern in the text that looks for the lettersM-i-s-s
that are next to each other.If we find the word
Miss
but also the wordMississippi
. If we tell the program that we don't care about upper and lower case letters we might also find the wordmissed
. So we are looking for a pattern where the four letters appear exactly in this order. This is already a regular expression.
...End of Excerpt. Please purchase the magazine to read the full article.