Re: [PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)

2006-05-25 Thread Kevin Waterson
This one time, at band camp, Micky Hulse [EMAIL PROTECTED] wrote:

 Hi all,
 
 I have been rtfm on preg_replace, and I am a bit turned-off by how 
 complex reg-exing appears to be anyway, I would like to spend some 
 time learning how I would convert a file full of links that look like:

Try this quicky

http://phpro.org/tutorials/Introduction-to-PHP-Regular-Expressions.html

Kevin

-- 
Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)

2006-05-25 Thread Micky Hulse

Koen Martens wrote:

You might be better off then by parsing the html file with DOM:

http://nl2.php.net/manual/en/ref.dom.php




Whoa, that is cool, I had no idea this was something PHP could do! 
Thanks for the links.  :D



Cheers,
Micky

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)

2006-05-25 Thread Micky Hulse

Kevin Waterson wrote:

Try this quicky
http://phpro.org/tutorials/Introduction-to-PHP-Regular-Expressions.html 


Sweet, good links all. Thanks for sharing!  :)

Have a great day.

Cheers,
Micky

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)

2006-05-25 Thread Eric Butera

On 5/25/06, Micky Hulse [EMAIL PROTECTED] wrote:

Kevin Waterson wrote:
 Try this quicky
 http://phpro.org/tutorials/Introduction-to-PHP-Regular-Expressions.html

Sweet, good links all. Thanks for sharing!  :)

Have a great day.

Cheers,
Micky

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




I built something similar to the situation that you are describing.
One difference though is I used preg_replace_callback
(http://us2.php.net/preg_replace_callback) so that I can do custom
scripting with the matched string to be replaced.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)

2006-05-25 Thread Adam Zey

Eric Butera wrote:

On 5/25/06, Micky Hulse [EMAIL PROTECTED] wrote:


Kevin Waterson wrote:
 Try this quicky
 http://phpro.org/tutorials/Introduction-to-PHP-Regular-Expressions.html

Sweet, good links all. Thanks for sharing!  :)

Have a great day.

Cheers,
Micky

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




I built something similar to the situation that you are describing.
One difference though is I used preg_replace_callback
(http://us2.php.net/preg_replace_callback) so that I can do custom
scripting with the matched string to be replaced.


I know I'm entering this discussion a bit late, but one tool that I've 
found indispensible in writing regular expressions (even after knowing 
how to write them) is The Regex Coach (http://www.weitz.de/regex-coach) 
(Free, and runs on Windows and Linux).


Essentially, you paste the text to search into the bottom textbox, and 
then start typing your regular expression into the top one. As you type, 
it shows you what it is matching in the bottom one. It can also show you 
what individual submatches are matching, and all sorts of neat stuff. 
So, if I have an HTML web page and I want to suck some specific 
information out of it, I'll paste the information in, write up a regex, 
and make sure it's matching what it's supposed to. But the feedback AS 
you're typing it is super handy. For example, if I have a regex, and I 
add a [a-z], then the indicator will show it matching the next 
character, then if I add *, the text selection will expand to show it 
matching the rest of the letters, and so on.


Anyhow, I find the feedback as I write a regex to be addictively useful.

Regards, Adam Zey.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)

2006-05-24 Thread Micky Hulse

Hi all,

I have been rtfm on preg_replace, and I am a bit turned-off by how 
complex reg-exing appears to be anyway, I would like to spend some 
time learning how I would convert a file full of links that look like:


A HREF=/viewentry.asp?ID=343323PT=PERSONALITIES TARGET=_topFake Link 
1/A

A HREF=/viewentry.asp?ID=328474PT=PERSONALITIESFake Link 2/A
A HREF=/viewentry.asp?ID=340492PT=PERSONALITIESFake Link 3/A
A HREF=/viewentry.asp?ID=339795PT=PERSONALITIESFake Link 4/A


And make them look like this:


a 
href=http://www.site.com/viewentry.asp?ID=343323amp;PT=PERSONALITIES; 
target=_blankFake Link 1/a
a 
href=http://www.site.com/viewentry.asp?ID=328474amp;PT=PERSONALITIES; 
target=_blankFake Link 2/a
a 
href=http://www.site.com/viewentry.asp?ID=340492amp;PT=PERSONALITIES; 
target=_blankFake Link 3/a
a 
href=http://www.site.com/viewentry.asp?ID=339795amp;PT=PERSONALITIES; 
target=_blankFake Link 4/a



Basically, I would like to make the links/code xhtml transitional, make 
the links absolute, add quotes where needed, convert  to amp;, and 
make them open in a blank window... it would be cool to trash everything 
except for the url and link description (in other words, if any of the 
links have, for example, TARGET=_top, it would just ignore and grab only 
what I want from source file


Any good links to tutorials and/or resources that teach one how to scrub 
urls with PHP and regex?


Many TIA!
Cheers,
Micky

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)

2006-05-24 Thread Micky Hulse

Micky Hulse wrote:
Any good links to tutorials and/or resources that teach one how to scrub 
urls with PHP and regex?


Ah, missed this in the comment section of the manual:

http://www.tote-taste.de/X-Project/regex/index.php

Looks like a good place to start.  :)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)

2006-05-24 Thread Ryan A


--- Micky Hulse [EMAIL PROTECTED] wrote:

 Micky Hulse wrote:
  Any good links to tutorials and/or resources that
 teach one how to scrub 
  urls with PHP and regex?
 

Hey,
Am learning from here:

http://weblogtoolscollection.com/regex/regex.php

found it via google

(note: Am in NO way connected to that site)

HTHs...Cheers,
Ryan


--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] preg_replace learning resources? Regex tuts? Tips? (and yes, I have been rtfm)

2006-05-24 Thread Micky Hulse

Ryan A wrote:

http://weblogtoolscollection.com/regex/regex.php
HTHs...Cheers,


Yeah, looks like a great resource, thanks!  :)

Cheers,
m

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php