TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-30-2008, 08:01 PM   #1 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default RegEx

Doh. Me again.

Well, been exploring the fields of RegExes and I do not understand anything of it to be exact. I am trying to write a RegEx to filter out a string like {MYTEXT} and replace it while I am doing it.

I don't know where to start off actually. Help?
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 04-30-2008, 08:16 PM   #2 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

Regular-Expressions.info - Regex Tutorial, Examples and Reference - Regexp Patterns
Regular Expressions Cheat Sheet - Cheat Sheets - ILoveJackDaniels.com

and finally,

preg_match()
preg_replace()

For "mytext", if that was the literal string, you could

echo preg_replace("~(mytext)~", "newtext", $szString);

...for a real basic example.
-m
delayedinsanity is offline  
Reply With Quote
Old 05-01-2008, 09:51 AM   #3 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

Thanks a lot! I am surely going to look in to that! Owe ya.
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 05-08-2008, 05:55 PM   #4 (permalink)
The Contributor
RegEx Guru 
 
Join Date: Dec 2007
Location: Belgium
Posts: 60
Thanks: 6
Geert is on a distinguished road
Default

Buy this book: O'Reilly Media | Mastering Regular Expressions
__________________
Kohana - PHP5 framework
Geert is offline  
Reply With Quote
Old 05-08-2008, 06:03 PM   #5 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Geert View Post
Usually books never helped me, I just learned from tutorials online. :P
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 05-08-2008, 06:05 PM   #6 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

By the way, you just want to rid of some text? lol just do
PHP Code:

$string 
preg_replace('/My text/','ttt',$string); 
which replaces My text with ttt in $string;
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 05-08-2008, 06:06 PM   #7 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

Nah, some books are great.

apress are my favourite so far. Everywhere I went looking for books, all I could find were the same old PHP books from various publishers - you know the ones, this is a variable, this is a control structure, this is how you write a basic little form handler script, and aren't you glad you read 500 pages so you could learn the same thing you could learn from the manual in a fifth of that? I went looking on Amazon and found apress/Matt Zandstra's PHP Objects, Patterns, and Practice, and Pro PHP, two books I would highly recommend, and I'm not even done reading them yet. Some excellent reference, examples, and a lot of things the manual doesn't go anywhere near covering.
-m
delayedinsanity is offline  
Reply With Quote
Old 05-08-2008, 07:47 PM   #8 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by delayedinsanity View Post
Nah, some books are great.

apress are my favourite so far. Everywhere I went looking for books, all I could find were the same old PHP books from various publishers - you know the ones, this is a variable, this is a control structure, this is how you write a basic little form handler script, and aren't you glad you read 500 pages so you could learn the same thing you could learn from the manual in a fifth of that? I went looking on Amazon and found apress/Matt Zandstra's PHP Objects, Patterns, and Practice, and Pro PHP, two books I would highly recommend, and I'm not even done reading them yet. Some excellent reference, examples, and a lot of things the manual doesn't go anywhere near covering.
-m
Lol, I've tried books of many types, including design patterns, C++, Java, Python, Pro Ajax, and more..

They were alright, they had some good tutorials, but in the end the internet won my vote. lol
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 05-09-2008, 10:17 AM   #9 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

+1 for Mastering Regular Expressions by O'Reilly

Great book, indeed. I've actually managed to write it from the beginning to the end and it definitely cleared some things up for me.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 05-10-2008, 08:48 AM   #10 (permalink)
The Contributor
RegEx Guru 
 
Join Date: Dec 2007
Location: Belgium
Posts: 60
Thanks: 6
Geert is on a distinguished road
Default

Quote:
Originally Posted by Orc View Post
Usually books never helped me, I just learned from tutorials online. :P
Take my word for it. I learn most stuff from internet resources as well, however Mastering Regular Expressions is a book that goes way more in-depth than anything I ever read about regular expressions online.

Quote:
Originally Posted by xenon View Post
+1 for Mastering Regular Expressions by O'Reilly

Great book, indeed. I've actually managed to write it from the beginning to the end and it definitely cleared some things up for me.
Glad you liked it too. By the way, you managed to write it?
__________________
Kohana - PHP5 framework
Geert is offline  
Reply With Quote
Old 05-10-2008, 01:01 PM   #11 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

My bad. I meant read it
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 05:13 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design