GroupBrowser  




Go Back   GroupBrowser > Macromedia Newsgroups > Coldfusion > Coldfusion Advanced Techniques
User Name
Password
 
 
Thread Tools Search this Thread Display Modes

wildcards in replace command?
Old 09-16-2005, 03:26 PM #1
jjsand28
Guest
 
Status:
Posts: n/a
Default wildcards in replace command?

Is there a way to use wildcards in the replace command?

I'd like to strip the html from text boxes before we put it into the database.
This is what I wrote but it doesn't work.

<cfset form.textbox = ReplaceNoCase(form.textbox,"<a href="*">","","all")>

I downloaded a html stripper that has this code in it but I don't understand
it and it doesn't seem to work.

<!--- Do replacement work here --->
<cfset temp = SetVariable("caller.#attributes.variable#",
REReplaceNoCase(attributes.input, "<[^[:space:]][^>]*>", "", "ALL"))>




  Reply With Quote

Re: wildcards in replace command?
Old 09-16-2005, 03:45 PM #2
mxstu
Guest
 
Status:
Posts: n/a
Default Re: wildcards in replace command?

You might want to take a look at cflib.org's http://www.cflib.org/udf.cfm?ID=12 UDF.
  Reply With Quote

Re: wildcards in replace command?
Old 09-16-2005, 04:12 PM #3
jjsand28
Guest
 
Status:
Posts: n/a
Default Re: wildcards in replace command?

still not working
  Reply With Quote

Re: wildcards in replace command?
Old 09-16-2005, 04:14 PM #4
mxstu
Guest
 
Status:
Posts: n/a
Default Re: wildcards in replace command?

The UDF worked fine for me. Can you be more specific? Can you post some code with an example of the value(s) giving you problems?
  Reply With Quote

Re: wildcards in replace command?
Old 09-16-2005, 04:26 PM #5
jjsand28
Guest
 
Status:
Posts: n/a
Default Re: wildcards in replace command?

I added the line to the demoroize script.

This is how the precessing page is written:

<!--- format the comments field --->
<CFSET form.Comments = #boxFormat(form.Comments)#>

<CFSWITCH expression="#URL.Action#">
<CFCASE value="add">
<CFQUERY name="addEntry" datasource="#Application.dsn#">
insert into
guestbook(Name,Email,NoEmail,Location,Homepage,Com ments,IPAddress,EntryDate)
values('#form.Name#','#form.Email#',
<CFIF isdefined("form.Noemail")>1,<CFELSE>0,</CFIF>

'#form.Location#','#Homepage#','#form.Comments#',' #cgi.REMOTE_ADDR#','#DateForma
t(now())#')
</CFQUERY>

here is the end of the demoronize script

<CFSCRIPT>
// DEMORONIZE CODE BLOCK HERE

// remove html
field = REReplaceNoCase(field, "<[^>]*>","","ALL");
return field;
}
</CFSCRIPT>


  Reply With Quote

Re: wildcards in replace command?
Old 09-16-2005, 04:44 PM #6
jjsand28
Guest
 
Status:
Posts: n/a
Default Re: wildcards in replace command?

it does work fine. i was calling the demoronize script incorrectly
  Reply With Quote

Re: wildcards in replace command?
Old 09-16-2005, 04:44 PM #7
mxstu
Guest
 
Status:
Posts: n/a
Default Re: wildcards in replace command?

I'm not sure why you are using "return" in this context. I think that may be
the problem.

The following worked fine



<form method="post">
<input type="text" name="testValue" value='<a
href="http://www.SITENAME.com">sitename</a>'>
<input type="submit">
</form>

<cfif IsDefined("form.testValue")>
<cfscript>
newValue = REReplaceNoCase(form.testValue, "<[^>]*>","","ALL");
</cfscript>
<cfoutput>
<b>orig:</b> #HTMLEditFormat(form.testValue)#<br>
<b>new:</b> #HTMLEditFormat(newValue)#
</cfoutput>
</cfif>

  Reply With Quote

Re: wildcards in replace command?
Old 09-16-2005, 04:45 PM #8
jjsand28
Guest
 
Status:
Posts: n/a
Default Re: wildcards in replace command?

can you explain how this code works? I don't understand the markup.
  Reply With Quote

Re: wildcards in replace command?
Old 09-16-2005, 04:47 PM #9
mxstu
Guest
 
Status:
Posts: n/a
Default Re: wildcards in replace command?

You mean the UDF itself: stripHTML() .... or ...the regular expression : REReplaceNoCase(field, "<[^>]*>","","ALL");
  Reply With Quote

Re: wildcards in replace command?
Old 09-16-2005, 04:55 PM #10
jjsand28
Guest
 
Status:
Posts: n/a
Default Re: wildcards in replace command?

sorry this part of the code

REReplaceNoCase(field, "<[^>]*>","","ALL");
  Reply With Quote
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes





Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump




Adobe Newsgroups | Software Newsgroups


Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2003-2004 All Rights Reserved GroupBrowser LLC.