Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Rexep for [url] with Name and link and URL

Quote Reply
Rexep for [url] with Name and link and URL
http://www.gossamer-threads.com/...t_reply;so=ASC;mh=-1;[/url]

There is an excellent thread for passing and rexep tags like
Think, its an easy rexep (for someone who understands this cryptical things ;-)

Robert
Quote Reply
Re: [Robert] Rexep for [url] with Name and link and URL In reply to
How about doing it like this?

[url "http://www.someurl.com"]some text[/url]

So...:

my $string = '[url "http://www.someurl.com"]some text[/url]';

$string =~ s,\[url\s+"([^"]+)"\]([^\[]+)\[/url\],<a href="$1">$2</a>,sg;

Last edited by:

RedRum: Mar 1, 2002, 2:41 PM
Quote Reply
Re: [RedRum] Rexep for [url] with Name and link and URL In reply to
A helpful hand in a drak night ;-)

I have found this for now:

$text ="[link]www.copy.de Linktext[/link]";
$text =~ s,\[link\](\S+)(.*)\[\/link\],<a href=\"http://$1\">$2</a>,g;

makes:
a href="http://www.copy.de"> Linktext</a


The problem is still the space, with \S+ i test till a space, but i must test better till a comma e.g.
Then it could go:

[link]gt.com,Linktext[/link]

Its important to me, to write less as possible in a text (cause we have a lot of texts inside the page ;-)



Just another easy one for you, i hope:

test on /text/ or /text/text/ or /text/..../text/
and print: a href=/.../

cause my cats are still at the root, i can link them with /cars/sportcars/

Robert

Last edited by:

Robert: Mar 1, 2002, 3:49 PM
Quote Reply
Re: [Robert] Rexep for [url] with Name and link and URL In reply to
Why not use my example above?

>>

Just another easy one for you, i hope:

test on /text/ or /text/text/ or /text/..../text/
and print: a href=/.../


<<

What do you mean?

Last edited by:

RedRum: Mar 1, 2002, 3:52 PM
Quote Reply
Re: [RedRum] Rexep for [url] with Name and link and URL In reply to
Hmm, cause i dont understand it ;-(

Code:
my $string = 'some text';

$string =~ s,\[url\s+"([^"]+)"\]([^\[]+)\[/url\],<a href="$1">$2</a>,sg;


s, replace
\[url hit [url ; \ escapes [

\s whitespace between +)" ???
is
-----
+ ?
" Char "
( Between () = $1
[^"] Everthing till " ?
+ many chars as want ?
) End of the ()
-----
\] End of http://\[/url\] hit

, followed by replacement
<a href="$1">$2</a> replacement
, further orders
s ?
g equal upper/lowercase
;

Hmm; your version has the advantage to use http and https;
but i want it as short as possible.

Will try to change it to:

string= [link]gt.com,Link text[/link]

The best would be a test, if http or https; else write it.


The other thing im trying is:

string='/category/subcat/..../subcat/';
string =~s, ???, a href=/category/subcat/>/category/subcat/</a

Last edited by:

Robert: Mar 1, 2002, 4:44 PM
Quote Reply
Re: [Robert] Rexep for [url] with Name and link and URL In reply to
Quote:
$string =~ s,\[url\s+"([^"]+)"\]([^\[]+)\[/url\],<a href="$1">$2</a>,sg;

Code:
\[ # Escape character class bracket

url\s+ # Match url plus one or more spaces

"([^"]+)" # Match "anything_up_to_another" and assign to $1

\] # Escape character class again

([^\[]+) # Match everything up to [ and assign to $2

\[/url\] # Match [/url]

Last edited by:

RedRum: Mar 1, 2002, 4:39 PM
Quote Reply
Re: [RedRum] Rexep for [url] with Name and link and URL In reply to
If you write it it sound very clear ;-)
Thank you.

For the other thing, i tried:

$text=~ s,\[cat\]/(\S+/)+\[/cat],<a href=\"/$1\">$1</a>,g;

Should hit:

Code:
[cat]/category/subcat/...subcat/[/cat]


Last edited by:

Robert: Mar 1, 2002, 4:52 PM
Quote Reply
Re: [Robert] Rexep for [url] with Name and link and URL In reply to
Try:

Code:
$text=~ s,\[cat\]([\w/]+)\[/cat\],<a href="$1">$1</a>,g;

If you stick with your original code you'll need to change:

\[/cat]

to

\[/cat\]

Last edited by:

RedRum: Mar 1, 2002, 4:57 PM
Quote Reply
Re: [RedRum] Rexep for [url] with Name and link and URL In reply to
Thank u, again. Robert
Quote Reply
Re: [Robert] Rexep for [url] with Name and link and URL In reply to
Hi RedRum again, seems there must be an error in your rexep:

I have tried this (and my own):

Code:
my $tmp ='[lnk "bundesrecht.juris.de/bundesrecht/urhg/index.html"]UrhG[/lnk]';
tmp=~ =~ s,\[lnk\s+"([^"]+)"\]([^\[]+)\[/lnk\],<a href="$1">$2</a>,sg;

and
my $tmp ='[lnk]bundesrecht.juris.de/bundesrecht/urhg/index.html"UrhG[/lnk]';
$tmp=~ s,\[lnk\]\s+([^"]+)"([^\[]+)\[/lnk\],<a href="http://$1">$2</a>,sg;


Robert
Quote Reply
Re: [Robert] Rexep for [url] with Name and link and URL In reply to
Code:


$tmp=~ s,\[lnk\](\S+)([^\[]+)\[/lnk\],<a href=\"http://$1\[/url]" target=_blank>$2</a>,g;


for [lnk]url without http:// some text[/lnk]


Divided by space, this is running now finde.
What i dont understand is:

If this is ok as it seems
([^\[]+) takes everything till ] without ]

why
([^\,]+) dont run ?!

Robert
Quote Reply
Re: [Robert] Rexep for [url] with Name and link and URL In reply to
You could just use (.*?) but I like to be different :)
Quote Reply
Re: [RedRum] Rexep for [url] with Name and link and URL In reply to
Sorry, what i want to say with the posting above is that your rexep isnt correct:

Code:
my $tmp ='[lnk "bundesrecht.juris.de/bundesrecht/urhg/index.html"]UrhG[/lnk]';
tmp=~ =~ s,\[lnk\s+"([^"]+)"\]([^\[]+)\[/lnk\],<a href="$1">$2</a>,sg;

and
my $tmp ='[lnk]bundesrecht.juris.de/bundesrecht/urhg/index.html"UrhG[/lnk]';
$tmp=~ s,\[lnk\]\s+([^"]+)"([^\[]+)\[/lnk\],<a href="http://$1">$2</a>,sg;

both versions, yours and the modified from me, dont hit the $tmp.

Code:
$tmp=~ s,\[lnk\](\S+)([^\[]+)\[/lnk\],<a href=\"http://$1\[/url]" target=_blank>$2</a>,g;
for [lnk]url without http:// some text[/lnk]

This one is okay, but it makes no sense for me, that your orginal doesnt run ?!
Plz try it for yourself (yours!) and maybe you will see the error that i cant find here.
Robert
Quote Reply
Re: [Robert] Rexep for [url] with Name and link and URL In reply to
It is correct, but you copied it incorrectly :)

Remove the second occurance of =~

Cool

Last edited by:

RedRum: Mar 8, 2002, 2:45 AM
Quote Reply
Re: [RedRum] Rexep for [url] with Name and link and URL In reply to
No, it is not correct.
The double =~ is not inside the global, else i would get an error while building.
Itīs only in the text here at the forum.
I have tested it a thousand times, i understand the sysnatx as you described it, but it do not hit !
Pleas etry it for yourself.

Robert
Quote Reply
Re: [Robert] Rexep for [url] with Name and link and URL In reply to
I did test it (always do before posting) and it works fine for me.

I need more info to find out the problem. What actually is not working?....what happens?