Link to home
Start Free TrialLog in
Avatar of Wayne Barron
Wayne BarronFlag for United States of America

asked on

var rightText = RegExp.$3 - Need leftText

Hello All;

In my site that Hielo helped me in.
It is JavaScript based, and this function

var rightText = RegExp.$3

case '[url': 
var temp=attributes.split('|');
return '<a href="'+temp[0]+'" title="'+temp[1]+'" target="_blank" rel="nofollow">'+temp[1]+'</a>&#171;'+rightText;

Open in new window


Of which allows for text on the right side.
I need it to allow text on the left as well.

Basically.

hello, this is a link [url:www.example.com|Example] that you can click on.

Right now, it will not display as a link, as there is text on the left side,  it will only display the actually code.
So, what I am needing, is the leftText to be added in.

Any help on this will be great.
Carrzkiss
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Here it is in vbs

<%
str="hello, this is a link [url:www.example.com|Example] that you can click on."
leftside=mid(str,instr(1,str,"www",1),instr(1,str,"|",1)-instr(1,str,"www",1) )
rightside=mid(str,instr(1,str,"|",1)+1,instr(1,str,"]",1)-1-instr(1,str,"|",1) )
response.write leftside
response.write "|"&rightside
%>

Open in new window

If I remember correctly, there were two functions:
process and bbFilter.  You need to call proccess passing bbFilter as the the second argument:
Response.Write( process(inputStr, bbFilter) )

Open in new window


It sounds like you are simply calling it as:
Response.Write( process(inputStr) )

Open in new window

Avatar of Wayne Barron

ASKER

Hielo.
I am doing it as the 1st one, exactly.
It has been like that since the code was first done.

padas, the whole page is done in JavaScript, I will be unable to change it to vbscript.
Though that is my comfort zone, I cannot change it now.
Maybe in the future, I can look at a possible convert.
Also, to Hielo.
If I do the [[info|Information Here]]
This works no matter where it is located at, in the middle of text, before, after, works perfectly.

It is only the code like what I supplied above, that does not work in the middle, or the end, only the beginning.
Can you provide a sample input string?
As sample is as I provided above.
Check out [url:www.eperts-exchange.com|Eperts Exchange] for your project needs and help

It does not matter rather there is 1 or many url's on the same line of not, they will not work if there is text on the "LEFT" side of the tag.
Very similar in js http://jsfiddle.net/ECxXF/

var str = "hello, this is a link [url:www.example.com|Example] that you can click on.";

var left1=str.indexOf('[')+5;
var left2=str.indexOf('|');
var right1=str.indexOf('|')+1;
var right2=str.indexOf(']');

document.write  (str.substring(left1,left2));
document.write ("<br>");
document.write  (str.substring(right1,right2));

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just tested it in the demo page, and now on my working testing server,
And it works like a champ.

Thanks a bunch Hielo!!
You Rock!!!