Current location: Hot Scripts Forums » Programming Languages » PHP » PHP regular expression problem


PHP regular expression problem

Reply
  #1 (permalink)  
Old 08-08-08, 03:58 AM
coolsaggu's Avatar
coolsaggu coolsaggu is offline
Newbie Coder
 
Join Date: Jun 2008
Location: New Delhi, INDIA
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
PHP regular expression problem

Hi all,
I am trying to create a regular expression but i'm not 100% successful in it. I hope some body can help me out.

Here is the situation. I have the string as shown below

Code:
I will be sending one more message

> I am fine. tell about yours
>
> > Hi, What are you doing
> >
> > I hope you are fine
I want to replace the > with <div>tag

so i created this regular expression and used in preg_replace

PHP Code:

preg_replace('/(>){1}/''<div style="border-left:3px #333333 solid; padding-left:5px;">'$messageContent, -1$count); 

and then using the for loop till $count i closed the <div> tag.

but the output that i get is quite different.

I will be sending one more message. I will replace <div> tag by pipe symbol ( | )

| I am fine. tell about yours
| |
| | | | Hi, What are you doing
| | | | | |
| | | | | | | | I hope you are fine

but i want this output. That is the replacement be only made in that scenario where <br> tag is not joining the '>' symbol. And if there are more than one instances of '>' symbol then only one replacement will be made

| I am fine. tell about yours
|
| | Hi, What are you doing
| |
| | I hope you are fine

Can somebody help me out
__________________
[ DEVELOPER - Dignity, Energy, Vision, Enthusiasm, Loyalty, Open-minded, Punctuality, Ex-telligence (extra intelligence), Respect ]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
can someone help with htaccess and php problem tigherrdk PHP 6 03-09-09 03:28 AM
Regular expressions problem in php EvilDeveloper PHP 2 07-13-08 07:02 AM
Mastering Regular Expressions in PHP rorycanyon PHP 0 10-24-05 08:27 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-25-05 12:09 AM
suggest a regular expression gmadhukarreddy Perl 2 01-08-04 01:56 AM


All times are GMT -5. The time now is 03:30 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.