Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 25th, 2005, 07:09 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default create strings of given regular expression

Hi friends,

Is there any way I can create strings that match a given regular expression ?

I will create or choose some regular expression in the course of program. It should then generate some strings that match this regular expression.

For e.g. if the regular expression is Product[1-9]+, it should generate some strings like Product1, Product2, Product3, ...., Product9, product10, .... etc. etc.

This should be done in general. This means the script should parse the regular expression and intelligently build strings out of it.

May anybody help me please ?

Thanks

Madhu
 
Old July 28th, 2005, 02:22 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

There is a way; I'm not working out your example; I've worked one example for myself; one week before:

$comment = preg_replace("/(\[color=)+([a-f0-9]{3})+(\])?/i", "<span style='color:\${2};'>", $comment);

Above matches BB-type [color=#RRGGBB] to <span style='color:#RRGGBB;'>
Especially, note tha ? in regular expression.

Please try now, yourself, for your original problem

http://www.mediasworks.com/tutorial/

 
Old July 28th, 2005, 11:48 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Thanks anshul. This gives me a ray of hope.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expression Help Please rstelma ASP.NET 1.0 and 1.1 Professional 0 January 2nd, 2008 07:01 PM
Regular Expression in C++ praveenholal C++ Programming 1 March 4th, 2007 01:18 AM
REGULAR EXPRESSION pallone Javascript How-To 0 September 5th, 2006 06:52 AM
regular expression if-then smay Javascript 4 July 5th, 2005 12:10 PM
Regular expression help!!! alex_read Javascript 4 August 18th, 2004 03:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.