mitchenall.com - The Database & Web Enabling Company  
Services Products Resources Contacts
* Consultancy
* Training
* Bespoke Development
* Web Development and Hosting
* Consultancy
* Training
* Bespoke Development
* Web Development and Hosting
* Consultancy
* Training
* Bespoke Development
* Web Development and Hosting
* Consultancy
* Training
* Bespoke Development
* Web Development and Hosting

> Home > Resources > Articles & Tutorials > 4th Dimension

Resources4th Dimension

Using Regular Expressions in 4D

Regular expressions are an extremely powerful tool for describing text. They're often included as a power user feature in many text editors and word-processors and many langauges and development environments have built-in support for them.

Regular expressions are a late entrant into the 4D family of products, and even now are only available through 3rd Party Plug-ins. Hopefully, 4D will address this and have native support built-in, but for the moment, the choices available for using regular expressions in 4D are fairly good.

This article will not teach the reader how to write regular expressions, but rather give some ideas of where and how regular expressions can be used with 4D. It will hopefully show readers new to regular expressions just how useful they can be and give an incentive to go and learn how to write them for themselves. I am by no means an expert on regular expressions, but I'm learning more all the time and I encourage those 4D developers who currently don't know how to use them to learn about them, especially if any of your work involves text parsing of any kind.

There is an excellent book on regular expressions entitled, "Mastering Regular Expressions" by Jeffrey E. F. Friedl, which is an absolute must for anybody who wants to use and eventually master regular expressions. It's the first book I've read on the subject which does a good job of explaining how to use regular expressions to someone who has never used them before. Again, I will not try and teach regular expression in this article, but will instead provide links where you can find more information for yourself.

Since discovering Regular Expressions (or Regex patterns) a year or so ago I have wondered how I managed to live so long without them. I now use them regularly when programming in PHP or 4D, but also for editing HTML and other source code. For example, using regular expressions, creating the hyperlinked 4D source code on this website was very much easier than you would think. Creating the index of all the 4D commands was done with 1 simple regex applied to each page in the index of the manual. Converting the code was also done with a series of simple regular expressions and some other find and replace operations to create the XML. Then the PHP XML process puts the two together and along with the stylesheet I get formatted 4D code with hyperlinks on the commands. Using regular expressions this took no time at all and is completely reusable.

Note: This article will remain a "work in progress" for a while as we find out new ways to entice 4D developers into using regular expressions. Expect fairly regular updates to this article, if you would like to contribute some ideas, I'd love to hear from you.

Planet 4D

The first part of a tutorial on using Regular Expressions aimed at 4D developers is available in Planete 4D Issue 7, the French journal for 4D developers. Visit the Planete 4D website to order your copy.

Next Page


 
Article Sections
-> Using Regular Expressions in 4D
A short discussion on regular expressions and their use within 4D.
   
* When/How can Regular Expressions be used in 4D?
This section shows how and when Regular Expressions can be used within the 4D environment.
   
* Uses for Regular Expressions in your applications
Here we will look in more details at using regular expressions in your applications and the types of things they're useful for.
   
* Another potential application for Regular Expressions
Some more examples of regular expression usage in your applications.
   
* Using the preg_module
Examples of using the preg_module for regular expression matching.
   
* Using Regular Expressions in the Method Editor
Some examples of useful regular expressions for use with QCP 4.2's Regex find and replace functionality.
   
* Conclusion
The end of the article.
   
 
  For the XML source of this article, click here.
 
Related Links
Escape Information Services
Escape are the providers of the QFree freeware plug-in which provides fantastic regular expression support within the 4D environment. They are also the developers of QPix, QMedia and other 4D and QuickTime plug-ins.
   
Aparajita's World
3rd Party 4D Plug-in Developer. Author of the developer assistant QuickCode Pro, the advanced web toolkit, Active4D and ObjectTools, three of the best plug-ins available for 4D.
   

Other 4th Dimension Articles
Related Book Recommendations
 
Mastering Regular Expressions by Jeffrey E.F. Friedl
 
  This is probably the first and last book you will need on using and then mastering regular expressions. Once you've read the first couple of chapters of this book, you will wonder how you managed to last so long without them (assuming you've never used them before). It is extremely well written and illustrated for the task in hand and is a must for anyone interested this powerful text manipulation tool. Find out more at Amazon UK / Amazon US / Amazon France
 
  There are other book reviews in our recommended reading section

> Home > Resources > Articles & Tutorials > 4th Dimension

 
4D Solutions Partner Logo

Last modified: 19 December 2001 by webmaster@mitchenall.com

[Home]
[Services]
[Products]
[Resources]
[Contacts]
 
Toolbar Component Valid HTML 4.01!
© mitchenall.com
1999-2002
Valid CSS!