Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
sam504u #1
String Manipulatio
Hello All,
I am trying to replace a specific pattern in a string, but could not get it
working. Heres what I am trying to do:
Say for ex: I have a string (which is actually a dynamically generated
absolute file path)
org_str="/abc/xyz/one/two/three/four.cfm"
and for all such string I want to get rid of the first three directory levels,
so in this case my new string should be:
new_str="/two/three/four.cfm"
So what I want is a regular expression which will parse my original string and
remove the first three directory leves, giving me the rest of the string as it
is.
Has anybody done such kind of thing before !!! Please help, I have been trying
this since the last couple of hours....
All comments and responses appreciated.
Thanks in advance.
Regards,
Tom
sam504u Guest
-
Maintain query string and somehow auto refresh a pagewith that string intact
I have a drill down where on page one the user selects criteria to narrow down the search for a speicific group of employees(like all hired between... -
#7056 [Com]: Setting string variables to value starting with '<' cause string to be empty.
ID: 7056 Comment by: davidgjenkins at ntlworld dot com Reported By: tammy at synchronis dot com Status: Closed... -
string question: how to append x zeros to get fixed lenght string?
"Bob Barrows" <reb_01501@yahoo.com> wrote in message news:uuhVv4mcDHA.656@tk2msftngp13.phx.gbl... newstring = Right("0000000" & i,8) ;-p -
Cannot create an object of type 'System.String[]' from its representation 'String[] Array'
Hello, I am designing a .net custom control in VS.net 7.1 and my control exposes an array of strings which are supposed to be the items to show. To... -
String question: Returning portion of string with words surrounding highlighted search term?
I'm looking to find or create an ASP script that will take a string, examine it for a search term, and if it finds the search term in the string,... -
sam504u #2
Re: String Manipulatio
Hi Group,
Could anybody please get me through the solution to my problem ????
sam504u Guest
-
PaulH #3
Re: String Manipulatio
treat the string as a list delimited by "/":
<cfscript>
org_Str="/abc/xyz/one/two/three/four.cfm";
tmpStr=org_Str;
for (i=1; i LTE 3; i=i+1) {
tmpStr=listDeleteAt(tmpStr,1,"/");
}
writeoutput(tmpStr);
</cfscript>
PaulH Guest
-
sam504u #4
Re: String Manipulatio
Thanks Paul,
The code was awesome, works perfect ... I didnt knew you could write stuff in cfscript.
Thanks again really appreciate it ...
Tom
sam504u Guest
-
-
sam504u #6
Re: String Manipulatio
Hi Paul,
cfscript is fine .... thanks for the information though.
One more question for you Paul. I was looking for a functionality where a user
can make selections of files (by clicking checkboxs) and submit the form, the
result of which I want is to download those files from the remote server on to
the users local machine. Something like a "Save Target File as" option.
I have CFMX running on a Linux box . Initially I was thinking of using CFFTP
or CHTTP (get method) but none of this would allow me to download a file on
clients machines , or will they ???? I am not sure, probably I am confused.
Could you guide me in the matter?
Thanks for all the help ....
Tom
<!--- This is how my Caller File looks --->
<form method="post" action="process_file.cfm">
<cfoutput query="select_wa_virusfile">
<INPUT TYPE="CHECKBOX" NAME="selected"
value="#select_wa_virusfile.vf_originalfile#"> <b>Filename:</b><a
href="#select_wa_virusfile.vf_originalfile#">#sele ct_wa_virusfile.vf_originalfil
e#</a>
<b>Date:</b>#select_wa_virusfile.vf_modificationdate# <br />
</cfoutput>
<br /> <br />
<INPUT TYPE="SUBMIT" VALUE="Download Now">
--------------------------------------------------------------------------------
-----------------------------------------------
<!--- This is how I am trying to process the selected files for downloading
--->
<cfhttp
method = "Get"
url="http://#serverip#/#Quarantine_Location#/#unique_wa_virusfile.vf_quarantinef
ile#"
path=" ??????????? "
file="#unique_wa_virusfile.vf_quarantinefile#">
OR COULD HAVE BEEN using CFGET like this:
<!--- ########Open connection --->
<cfftp connection="Myftp"
server="#serverip#"
username="testing"
password="testing"
action="Open"
stoponerror="Yes"
passive="yes">
<cfftp connection="Myftp"
action="getFile"
localFile=" ????????? "
remoteFile="#tmp_Str#"
stoponerror="Yes"
passive="yes"
failIfExists="No">
<cfoutput> Status: #cfftp.returnValue# </cfoutput>
Close the connection after every use
<cfftp connection="Myftp"
action="close"
stoponerror="Yes">
<p>Connection closed successfully:<cfoutput>#cfftp.succeeded#</cfoutput>
But how will any of this work for downloading files from remote server to
client machines. What do I specify in the "localfile" or "path" of cfftp and
chttp respectively.
While I was looking aroung on the Web I found a CF_FileManager custom tag
developed by some third party company, which kind of does everything what i
need, like a Pop up window where you can select files and: dowload, delete,
rename etc but I dont wanna pay money for that.
Do you know if theres anything which is built-in in CFMX where I can achieve
this functionality.
Thanks again
sam504u Guest
-
PaulH #7
Re: String Manipulatio
you could either build a page with simple http links to these files or use the cfcontent tag to push these files at the client.
PaulH Guest
-
sam504u #8
Re: String Manipulatio
Hello Paul,
I went through the cfcontent documentaion, but it displays the content of the
called page on the clients Web browser, which is not what I want. I want that
the client should be able to save the file on his local machine, in that case I
think I just have to make a Web page with the http links to the files, which he
can "Right click" and choose "Save Target as" option.
Correct me if I am wrong ....
Tom
sam504u Guest
-
Adam Cameron #9
Re: String Manipulatio
I think you were on a better track when you were wanting to do it with a
regex.
Try this:
new_str = REReplace(org_str, "(/[^/]+){3}(.*)", "\2");
--
Adam
Adam Cameron Guest
-
PaulH #10
Re: String Manipulatio
yeah well regex has never been one of my strong points ;-) yes, this is indeed
better.
as far as cfcontent goes it might be something like this:
<cfheader name="Content-Disposition" value="inline;
filename=downloadFileNameGoesHere">
<cfcontent type="MIMEtypeGoesHere" file="fullPathToFileGoesHere">
PaulH Guest



Reply With Quote

