Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 1.1

FEATURE

Expressions of Delight

REALbasic's Regex class

Issue: 1.1 (August/September 2002)
Author: Matt Neuburg
Author Bio: Matt Neuburg first learned about regular expressions while using the Nisus word processor in 1990, and hasn't had a good night's sleep since.
Article Description: How to use regular expressions in REALbasic
Article Length (in bytes): 23,888
Starting Page Number: 24
Article Number: 1005
Resource File(s):

Download Icon 1005.zip Updated: 2013-03-11 19:07:55

Related Link(s): None

Excerpt of article text...

The Regex class, along with the RegexMatch, RegexOptions, and RegexException classes, is the gateway to REALbasic's implementation of regular expressions. Regular expressions are a way of expressing a textual find or find-and-replace that's too complicated, or too vague, for a function like InStr or Replace. To see what I mean, let's take an example.

Suppose you've got a string representing some HTML, and you want to remove all the HTML markup from it. An HTML tag starts with a left angle-bracket and ends with a right angle-bracket; the tag consists of both angle-brackets, and everything in between, like this: "<TAG>". The trouble is, of course, that you don't know in advance what "everything in between" consists of.

So how would you find and remove an HTML tag using just InStr? You'd have to take a piecemeal approach. First you'd have to find a left angle-bracket, and remember where it is. Then you'd look for a right angle-bracket that comes after the left angle-bracket, and remember where it is. Then you'd have to break up the string into three pieces & what precedes the tag, the tag itself, and what follows the tag & and reassemble it without the middle piece, thus deleting the tag. Here's some actual code.

Manual removal of HTML tag:

dim s, leftPart, rightPart as string

...End of Excerpt. Please purchase the magazine to read the full article.