galexcd
Oct 24 2006, 02:56 AM
| | I must be a total noob, or just really tired...............-.- either way, I cannot understand what exactly those funky strings preg_replace wants for the pattern.
Could sombody explain to me exactly what the pattern string and the replace string in preg replace does?
I get str_replace... that's quite basic.
I considered myself a pro at php until tonight........haha shows how much i know. I bet tomorow, if i look it up I'll get it....
Anyway.. any help? Thanks.....  |
Reply
electron
Oct 24 2006, 04:29 AM
It needs a regular expression as a pattern. If you dont know that what are regular expressions it is quite simple to leasrn it. Just google it out OR go visit the php.net site where they have explained the whole function in details and read the comments below. That help alot and have links to some great PHP related regular expressions. But if you are using preg_replace to takecare of HTML tags or BBCODE it is useless. Hope that helps
Reply
galexcd
Oct 24 2006, 04:55 AM
Great help.. Thanks, but why is it useless for bb code? because that's the reason I wanted to know.. Right now my message boards sorta suck because I'm using str_replace fore the bbcode, It's sorta annoying how you have to put url name every time, instead of also allowing http://www.mydomain.com. I've also got a flash chat, and stupid flash's html has to be perfect, so <b><i>text</b></i> would leave the bold modifyer on. I was hoping for a way to use preg_replace to disable bbcode within bbcode for the chat.
Reply
electron
Oct 25 2006, 08:58 AM
Well if you are using it for URL it is fine but make sure to make it ungreedy so that it matches not the whole thing but first start and first end. Let me see if i have that for the URL stuff.
Reply
Recent Queries:--
preg_replace replace - 689.52 hr back. (1)
-
preg_replace funky characters - 1011.34 hr back. (1)
Similar Topics
Keywords : preg, replace
- A Simple Preg_replace Help Please.
(2)
Preg Replace Problem
(1) If i have a word like c.........a......t (with the dots in) and i wanted to replace it with cat how
would i do it. If i use CODE <?php $patterns =
"/c(*)a(*)t/"; $replace = "cat"; echo
preg_replace($patterns, $replace, 'c.....a.........t');
[/color][color="#000000"]?> then when i type something like "
c ome a nd look at t his" is also filtered. Is
there any way just to filter cat with dots in? ....
Php Preg Replace
(1) Ive got a problem with preg replace, this is the code: display.php CODE <table
border="1"> <tr><th width="70">Time</th><th
width="200">IP</th><th
width="70">Viewed</th></tr> <?php $LogData =
file_get_contents("log.txt"); $Find =
"/||(.*)|(.*)|(.*)||/i"; $Replace =
"<tr><td>$1</td><td>$2</td><td>$3
</td></tr>"; ....
Validation Script - Detecting Illegal Characters
preg_match to find illegal characters (0) I'm trying to validate a user's desired username for a registration page. I want to detect
any illegal characters being used for a username. So far i have managed to include most execpt the
'\', the '\' is used for escape and treating the preceding characters
literally. I try to do '\\' but i get an error because it execects another
character. CODE $ck_result = "Default"; $pattern =
"/[!|@|#|$|%|^|&|*|(|)|_|\-|=|+|\||,|.|\/|;|:|\'
;|\"|....
Preg_replace Problems
(7) Sigh... preg_replace is getting very annoying for me. Could sombody tell me what I'm doing
wrong? Im making a bbcode replace for the forums I made, and preg_replace is being a b****...
Right now Im working on the tag, and I want to check for valid URL's, because idiots in the
forum are adding js and stuff in the image tags and messing it all up. So i put a function in the
array that holds all of the replacements: CODE
$main_search=array('/\[b\](.*?)\[\/b\]
/is','/\[i\ ....
Replace A Character In A Specific Tag
(7) I need a code that replaces all spaces between ] brackets with an underscore. So, basically, I
write this into a variable: CODE bla bla something [[some text]] more text here
And I want a script to change it to this: CODE bla bla something [[some_text]]
more text here Any suggestions?....
Regexp Function Preg_match_all()
preg_match_all() - Help me (0) Hi, I got a new problem which has caused me to go mad but no solution. preg_match_all() - is the
problem. I have something like this: CODE [ol] [li]Test1[/li]
[li]Test2[/li] [li]Test3[/li] [li]Test4[/li]
[li]Test5[/li] [/ol] Some text.Some text.Some text. [ol]
[li]Test1[/li] [ol] [li]Test1[/li]
[li]Test2[/li] [li]Test3[/li] [li]Test4[/li]
[li]Test5[/li] &....
Help With Reading Files
Read and replace/insert data from form (5) Hi, Does anyone know how i can do this, or scripts that will work on Trap17's servers and will
do the following: I have a .doc file form. Which i want to have filled in automactically, by HTML
Form and emailed to my address, with the data filled in. Any ideas? I have heard many differing
things, like XML, RTF, DOC, PDF... I have serched through many places and come up empty handed with
anything that works. /sad.gif' border='0' style='vertical-align:middle' alt='sad.gif' /> ....
Replace Shtml With Php?
I don't know jack.... (1) I don't know anything about PHP, except that I use phpBB and have modified my forums template
files. I used to make web sites years ago and just got back into it a couple months ago. I wonder
if I should stop using shtml and switch to php. I don't really have time to learn php (at least
not yet), but if it's easy to replace my Server Side Include with php (just to be more "modern")
I would be willing to do so. Anyone have any suggestions about me doing so? Am I'm too old
school for using shtml? Lol /laugh.gif' border='0' style='vertical-align:middle' ....
Looking for preg, replace
|
*RANDOM STUFF*
*SIMILAR VIDEOS*
Searching Video's for preg, replace
*MORE FROM TRAP17.COM*
|
advertisement
|
|