Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Search and Replace String in a textfile

210 views
Skip to first unread message

Anna

unread,
May 14, 2004, 2:28:09 PM5/14/04
to
Does anybody have or know of a command/tool that I can call
inside PB Script that would accept a SEARCH string, REPLACE
string and filename? One that does not require manual input
from users.

TIA.

Terry Voth

unread,
May 14, 2004, 3:32:46 PM5/14/04
to
All the parts are in PFC:

String service: of_GlobalReplace
File Service: of_FileRead* and of_FileWrite (* this returns an array
of string, but it's easy to add functionality that returns a single
string)

If you don't want to use PFC, you can probably strip the code out.

Good luck,

Terry [TeamSybase] and Sequel the techno-kitten


Sequel's Sandbox: http://www.techno-kitten.com
Home of PBL Peeper, a free PowerBuilder Developer's Toolkit.
Version 2.2.06 now available at the Sandbox
See the PB Troubleshooting Guide at the Sandbox
^ ^
o o
=*=

Neil Rothschild

unread,
May 14, 2004, 4:48:00 PM5/14/04
to
If you don't like Terry's idea, try Funduc's search and replace. I use it
in gui mode but it does include command line capability.

http://www.funduc.com/search_replace.htm

Neil

<Anna> wrote in message news:40a50fb8.5b6...@sybase.com...

David

unread,
May 17, 2004, 8:06:08 AM5/17/04
to
Try this :

global function string f_s_replaceall (string as_source,
string as_lookfor, string as_replacewith);//
________________________________________________________________________________________

int li_start_pos=1,li_len_look_for

li_len_look_for = len(as_lookfor)

// Cherche la première occurence de la chaine
li_start_pos = Pos(as_source,as_lookfor,li_start_pos)

DO WHILE li_start_pos > 0
// Remplace l'occurence trouvée
as_source =
Replace(as_source,li_start_pos,li_Len_look_for,as_replacewith)
// Cherche l'occurence suivante
li_start_pos =
Pos(as_source,as_lookfor,li_start_pos+Len(as_replacewith))
LOOP

return as_source

end function

0 new messages