Quick Nav:  Online Store   |   Login | Register

Soooo close!

Rate this topic:

Please Register to post a reply. Another benefit of registration is the ability to subscribe to and recieve notifications of new posts.
AuthorMessages
Nelson Fernandez
<100 Posts
Posts:50


10/29/2007 2:52 PM  

My site uses ActiveFOrum 3.6 and I have been wanting to make urls automatically get converted into links. Well I am close....

I have a regex replacement that detects www.* and http://* .

 

The problem I have is that PB will only convert the first match.

so in other words if I had the following:

www.google.com

www.yahoo.com

only the google link would be created. It seems the regex only matches the first one. I suspect this is because I have told it only to do those it finds withing the afpostbody DIV. If I don't limit it to the afpostbody, I get artifacts on the top of my page because AF will attempt to put the post body of the first post into the head section.

Is there anyway to write the regex so it finds all instance within the div?

Here is the WWW code - hopefully the code won't reformat badly here...:

Find: (afpostbody.*?)(^|[>\n ])(www\.[^ <]*)
Replace with: $1$2< a target="_blank" href="http://$3" >$3

 

Host Account
<100 Posts
Posts:83


10/29/2007 3:01 PM  
The way I read it, that regex will find all instances inside the afpostbody div.
Your replacement doesn't look right though. It is basically just putting everything back the way it found it.
You captured three groups in the search, and put them all back in order in the replace.

If you have some example text that you can attach I'll test it with my regex tester to see if we can come up with something better.
Host Account
<100 Posts
Posts:83


10/29/2007 3:03 PM  
Oh, I bet you had the http part in the replace and the forums messed it up.

If you want to put the code in an attachement it may be easier.
Nelson Fernandez
<100 Posts
Posts:50


10/29/2007 3:05 PM  

Basically I'm looking for something like; www.google.com   and replacing it with [a href="wwww.google.com"]www.google.com[/a]  so that it becomes clickable.

 

Nelson Fernandez
<100 Posts
Posts:50


10/29/2007 3:07 PM  

attaching...


Attachment: linkregex.txt

Nelson Fernandez
<100 Posts
Posts:50


10/29/2007 3:08 PM  
note: if I don't limit it to the afpostbody it works great EXCEPT for the fact that AF will put it into the head section.
John Mitchell
Posts:3033


10/30/2007 11:53 AM  
Ok, this one is a stumper. I've tried every trick I know and I can't do any better.

Maybe we should approach it differently.
How about making a tag that your users can wrap a url with so that it builds a link out of it?
Something like


        [url]www.myurl.com[/url]


Nelson Fernandez
<100 Posts
Posts:50


10/30/2007 12:11 PM  
if I thought my users would go through the trouble of doing that I would go that direction, unfortunately they wont which is why I had to do this solution....

I wonder if I can clear the data that is placed into the head section instead?
John Mitchell
Posts:3033


10/30/2007 12:18 PM  
That's an idea. You would just have to do the opposite and remove any links inside the head section.
You may still run into the problem of trying to remove more than one link though.
Nelson Fernandez
<100 Posts
Posts:50


10/30/2007 1:01 PM  

the problem is in the meta tag that gets populated by AF. The following works in my regex tester but not via PB (replace square brackets with angled:

 

Find: ([meta id="MetaDescription" name="DESCRIPTION" content=")(.*?)("][meta)

Replace $1$3

 

Is PB ignoring the head section? Or could it me the process that populates that happens AFTER PB does it's work? Is there something I can do to insure PB is the last in the chain?

Please Register to post a reply. Another benefit of registration is the ability to subscribe to and recieve notifications of new posts.



ActiveForums 3.7
Powered by: Snapsis Software