forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


string.dll / search & replace question...

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
MarkTrubo
Contributor
Contributor


Joined: 27 May 2001
Posts: 148
Location: Long Island, NY

PostPosted: Mon Nov 14, 2005 11:22 am    Post subject: string.dll / search & replace question... Reply with quote

I'm using string.dll (which by-the-way is amazing) in a program that put the paths to some cgi scripts into html pages provided by clients. The cgi scripts endup being integrated into the links in the html, so I need to isolate all the external links.

Works great -- im using these string functions (obviously complete in the program):

%%myFileContent = @string(FileToVar, @ITEM(LB))
@string(GetURL,%%myFileContent,EXT)
@string(NoDupes,
@string(RegxFind,
@string(Replace,

I'm able to find and fix all external links that are on a single line, but if there is a line break, no good. This is an example of the problem:

Quote:
<DIV align=center><FONT face="Verdana, Arial, Helvetica, sans-serif"
color=#ffffff size=1>For more info - <A
href="http://www.somelinkhere.com/"><B><FONT
color=#ffff00>click here</FONT></B></A>


This function, @string(GetURL,%%myFileContent,EXT), does find the href line in this case, but I need to replace the whole thing including the "<A ", which is where my problem lies do to the line break.

If this were on one line it would be fine:
<A href="http://www.somelinkhere.com/">

But since the html comes form clients, sometimes links are not on one line
like this:
<A
href="http://www.somelinkhere.com/">

Ideas?
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Mon Nov 14, 2005 12:45 pm    Post subject: Reply with quote

When you run into this type of situation, I'd quote Yoda: Use the force... Wink

... the force here being regular expressions. You can work wonders with those.

Use RegxReplace to format your text prior to doing the other manips. Or use RegxRepInFile on the entire file.

BTW - be sure to write your regular expressions right or you may mess up things badly.

Greetz
Dr. Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
MarkTrubo
Contributor
Contributor


Joined: 27 May 2001
Posts: 148
Location: Long Island, NY

PostPosted: Mon Nov 14, 2005 5:12 pm    Post subject: Reply with quote

I read the descriptions, but did not really understand them. Maybe I need a Redbull infusion to make my brain work! Could you give me an example that addresses the issue I described?

Sorry for being lame today, I'm just not seeing it!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Tue Nov 15, 2005 7:23 am    Post subject: Reply with quote

Well, if ya don't mind putting everything into 1 line, ya could use @string(Xwhite, [input file as var], [CTRL]). Real easy.

Or perhaps a regex like

repeat
%%infile = @string(RegxReplace, %%infile, "<A(.*?)"[\t\n\r\f]"(.*?)</A>", "<A $1 $2</A>",)
until @equal(@string(CountRep,),0)
%%infile = @string(Xwhite, %%infile,CTRL)

Greetz
Dr. Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
MarkTrubo
Contributor
Contributor


Joined: 27 May 2001
Posts: 148
Location: Long Island, NY

PostPosted: Tue Nov 15, 2005 11:09 am    Post subject: Reply with quote

1) Thanks -- I'll try it!
2) Look at that formula... I'm sure I would have guessed that.... NOT! Thanks again!!!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
MarkTrubo
Contributor
Contributor


Joined: 27 May 2001
Posts: 148
Location: Long Island, NY

PostPosted: Tue Nov 15, 2005 11:39 am    Post subject: Reply with quote

OK, I put that in my program and yep, it worked fine. But, my HTML is all on one line. Anyway not to compress the html?
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Tue Nov 15, 2005 12:38 pm    Post subject: Reply with quote

Of course, it's all in 1 line coz I left the CTRL parameter in the Xwhite function Laughing

BTW, this might be better:

Code:
repeat
  %%infile = @string(RegxReplace, %%infile, "<A([^>]*?)[\t\n\r\f]([^>]*?)>", "<A $1 $2>",)
until @equal(@string(CountRep,),0)
%%line = @string(Xwhite, %%infile,)


Greetz
Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
MarkTrubo
Contributor
Contributor


Joined: 27 May 2001
Posts: 148
Location: Long Island, NY

PostPosted: Tue Nov 15, 2005 2:37 pm    Post subject: Reply with quote

Dread... you are the man! That worked great. Thank you so much!!!!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Tue Nov 15, 2005 3:05 pm    Post subject: Reply with quote

Glad it worked out. As I told ya - use the force...

Greetz
Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group