Reply to Re: Help me with a regular expression for PHP

Your name:

Reply:


Posted by Chung Leong on 10/30/06 14:04

cendrizzi wrote:
> No I didn't know that \w was the same. What do you mean by proper
> capturing. I really am a 2 year old when it comes to RE stuff.
>
> Thanks!
>
> On Oct 29, 10:04 pm, "Chung Leong" <chernyshev...@hotmail.com> wrote:
> > cendrizzi wrote:
> > > I have no idea where to get help on RE stuff. Since it's for a PHP app
> > > I thought I would ask here to see if there was some RE pros. Basically
> > > I'm doing some template stuff and I wanted to use a
> > > preg_replace_callback function to call another function when the
> > > criteria of the RE expression is matched but have no idea how to
> > > accomplish it.
> >
> > > So I start with this:
> > > /<(input|select|textarea)[^>]*name\s*\=\s*\"[_a-zA-Z0-9\s]*\"[^>]*>/
> >
> > > but need to modify it so it only matches if it has '{' characters in
> > > the name but to not match if it does not.
> >
> > > So this would not match:
> > > <input name="test">
> >
> > > But this would match:
> > > <input name="test{0}">
> >
> > > Thanks much in advance.Well, just change the [_a-zA-Z0-9\s]* part to [\w\s]*{[\w\s]*}. Of
> > course, you'll need to do proper capturing in order to form the
> > replacement string.
> >
> > \w is equivalent to [_a-zA-Z0-9] by the way.

By that I mean you need to grab the substrings which precedes and
follows the text inside the quotation marks. If the input is

<input name="test{0}" size="40">

you'd want

<input name="

and

" size="40">

so that you can form the replacement <input name=" + DATA + "
size="40">.

Presumably you'd want 'test' and '0' as well for looking up the data.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация