Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
Learn Regular Expressions
filburt1
Join Date: Feb 2002
Posts: 6,144

Maryland, US
by filburt1 filburt1 is offline 24 Apr 2003

This may look like pure nonsense:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

...but it converts anything in $s that's in the format "[mycode]something[/mycode]" to "<b>something</b>". This is thanks to regular expressions, a series of usually arcane-looking characters in a hideous and unreadable string that are extremely powerful once you know how to use them. vB uses them everywhere, and after I got over the very sharp learning curve, I use them everywhere I can now. You'd be amazed at how much it can simplify your code.

A regexp (or regex) reference that I use is at http://www.english.uga.edu/humcomp/perl/regex2a.html (that's for Perl but the expressions themselves are almost exactly the same). Also see http://www.php.net/preg_replace , http://www.php.net/preg_match , and http://www.php.net/preg_match_all , as well as all the other preg_...() functions.
Views: 2278
Reply With Quote
Comments
  #2  
Old 24 Apr 2003, 11:18
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Real name: Dean Clatworthy
Good tip filburt. I know how useful they are now

- miSt
__________________
Dean Clatworthy - Web Developer/Designer

Last edited by filburt1; 03 Jul 2003 at 14:41.
Reply With Quote
  #3  
Old 03 Jul 2003, 14:31
Kriek's Avatar
Kriek Kriek is offline
 
Join Date: Jul 2002
Real name: Jon Kriek
My Regular Expressions are rusty, but I wholeheartedly concur on their potency seeing that I now use them with REGEXP in MySQL queries, while previously only utilizing them within Perl or PHP. I highly recommend this article.
__________________
Jon Kriek Integer Doctor
A programmer is a machine for turning coffee into theorems.
[Suspend Thread Random Text Quotes Thread Torrent]
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 00:29.

Layout Options | Width: Wide Color: