preg_replace

preg_replace

am 02.11.2007 17:35:26 von Silvertype

Hi guys,

I have these html tags:





which I want to replace with the following tags:





I know that it can be done by using preg_replace but I haven't really
figured out how to use it. Any help would be greatly appreciated. Thanks in
advance.

Re: preg_replace

am 02.11.2007 19:40:25 von darko

On Nov 2, 5:35 pm, "Silvertype" wrote:
> Hi guys,
>
> I have these html tags:
>
>
>
>
>
> which I want to replace with the following tags:
>
>
>
>
>
> I know that it can be done by using preg_replace but I haven't really
> figured out how to use it. Any help would be greatly appreciated. Thanks in
> advance.

Hmm... are you trying to say that you want to add the same event
handler to all inputs and textareas, or this event handler depends on
the tag and its contents, and it's not only inputs and textareas?

Anyway, you should read about regular expressions (google search will
give you A LOT of information about them - google
search about regular expressions
), and php.net about preg_replace
(http://www.php.net/preg_replace). That's all you need.

Cheers

Re: preg_replace

am 02.11.2007 19:58:08 von Silvertype

Yup, I have looked into google already. There are indeed a lot of info on
regex but unfortunately, due to my closing project deadline, I do not have
time to go through all of them. Therefore, I would greatly appreciate if you
(or anyone reading this) can provide me with a slightly more comprehensive
solution. Thanks again.

"Darko" wrote in message
news:1194028825.531817.309290@z9g2000hsf.googlegroups.com...
> On Nov 2, 5:35 pm, "Silvertype" wrote:
>> Hi guys,
>>
>> I have these html tags:
>>
>>
>>
>>
>>
>> which I want to replace with the following tags:
>>
>>
>>
>>
>>
>> I know that it can be done by using preg_replace but I haven't really
>> figured out how to use it. Any help would be greatly appreciated. Thanks
>> in
>> advance.
>
> Hmm... are you trying to say that you want to add the same event
> handler to all inputs and textareas, or this event handler depends on
> the tag and its contents, and it's not only inputs and textareas?
>
> Anyway, you should read about regular expressions (google search will
> give you A LOT of information about them - google
> search about regular expressions
), and php.net about preg_replace
> (http://www.php.net/preg_replace). That's all you need.
>
> Cheers
>

Re: preg_replace

am 02.11.2007 21:44:16 von Lars Eighner

In our last episode, , the lovely and
talented Silvertype broadcast on comp.lang.php:

> Yup, I have looked into google already. There are indeed a lot of info on
> regex but unfortunately, due to my closing project deadline, I do not have
> time to go through all of them. Therefore, I would greatly appreciate if you
> (or anyone reading this) can provide me with a slightly more comprehensive
> solution. Thanks again.


Once again, you have not made clear what the nature of your problem is.

Perl itself, not php preg_replace, is the most effective way to search and
replace in a large number of files.

Even so, you would have to define the precise conditions under which you
want the replacement made. If you could do that, of course, your problem
would be easily solved if you consulted the manual on preg_replace.

Someone could, of course, give you function calls that would make the
replacement in the two strings you have given. But if you really needed to
change only these two strings, you would simply make the changes with a text
editor. Therefore, we all suppose your problem is more general (unless of
course it is homework). Do you want to add your "onclick" event to every
input element and every textarea element? Or are there particular
conditions on the ones you want to replace?

That returns us to the question of context. Where are the strings coming
from? Are you generating them? Are they static parts of pages that also
contain php? Are you serving the pages directly, or are you using php cli
to modify existing files?

In other words, it appears you cannot --- at least you have not --- defined
the problem.

Don't top post.

--
Lars Eighner
Countdown: 444 days to go.
What do you do when you're debranded?