|
-
Sep 22nd, 2002, 04:52 AM
#1
Thread Starter
Conquistador
Most likely a preg_replace question?
It's hard to explain so i'll provide an example:
If someone types "/me says hello" in a textbox, how can i parse this (using preg_replace) so that it will be displayed as:
<font color="red">* da_silvy says hello</font>
In a shoutbox?
Can someone please tell me the code for this
-
Sep 22nd, 2002, 12:48 PM
#2
Frenzied Member
well you would have to get the /me to be exchanged with the user name.
preg_replace('/(\/me)(.*)/U','$username //2, $string);
-
Sep 22nd, 2002, 11:17 PM
#3
Thread Starter
Conquistador
didn't seem to work 
Also, i want it to work for that line, so that when a /me appears on the start of the line, it will add a tag at the front and a tag at the end of the line..
-
Sep 23rd, 2002, 08:03 AM
#4
Stuck in the 80s
Re: Most likely a preg_replace question?
Originally posted by da_silvy
It's hard to explain so i'll provide an example:
If someone types "/me says hello" in a textbox, how can i parse this (using preg_replace) so that it will be displayed as:
<font color="red">* da_silvy says hello</font>
In a shoutbox?
Can someone please tell me the code for this
Code:
$string = preg_replace("/\me(*.)/\n", '<font color="read">' . $username . '\\1</font>', $string);
I'm not sure how to fit the newline in there, though. 
If I you haven't gotten a proven answer by the time I get home from school, I'll give it a shot.
-
Sep 23rd, 2002, 01:13 PM
#5
Frenzied Member
Originally posted by da_silvy
didn't seem to work 
Also, i want it to work for that line, so that when a /me appears on the start of the line, it will add a tag at the front and a tag at the end of the line..
sorry fogot to add that.
preg_replace('/(\/me)(.*)/U','<font color=red>'.$username.' //2</font>, $string);
-
Sep 23rd, 2002, 01:43 PM
#6
Fanatic Member
Error Correction on phpman's code:
PHP Code:
preg_replace('/(\/me)(.*)/U','<font color=red>'.$username.' //2</font>', $string);
(forgot a ')
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|