I don't think you need a regex for this.  Just populate a variable with the
default text and do a replace() on the incoming text before you test it for
length.  Something like:

crap = "default crap from SoEditor";
content = replace(content, crap, '');

This way, if the default crap is submitted, it gets removed.  Of course, if
they only add to the beginning or end, you might run into trouble.  You can
either deal with this by checking the length against the length of the
default content (what I'd do) or you can write an RE to do the replace
(which seems like overkill and is easier to goof up).

As far as good books go, Mastering Regular Expressions from O'Reilly is
pretty good, though not CF specific.  Of course, if you are using CFMX
(almost?) everything that works in Perl will work.  If you are using CF5,
between Advanced CF5 Programming and Mastering RE's, you ought to be able to
figure most things out.

<cfx_evangelism really_cool_thing="CF-RegEx">

And, if you need advice or have more in-depth questions, you can always go
to:
http://www.houseoffusion.com/cf_lists/index.cfm?method=threads&forumid=21
to read, post, or subscribe to the HoF CF-RegEx list.

So far, on the CF-Regex list, we've had discussions on the differences
between CF5 and MX REs, workarounds for limitations to the CF5 RE engine, a
posting on what looks like a very nice UDF for stripping HTMl/CFML/XML/*ML
tags (or not stripping them) via REs, and several questions asked and
answered.

</cfx_evangelism>


  --Ben Doom
    Programmer & General Lackey
    Moonbow Software

: -----Original Message-----
: From: Brook Davies [mailto:brook@;maracasmedia.com]
: Sent: Monday, October 21, 2002 2:48 PM
: To: CF-Talk
: Subject: SoEditor and RegEx help
:
:
: Hello,
:
: I'm using the SoEditor wyiwyg Editor and I need some help with a regular
: expression. The Soeditor when it is initially loaded prepopulates
: the text
: area with some basic html. Head and body tags etc.
:
: The problem I'm having with this is that if a user does not enter
: anything,
: it still looks like there is content in the textarea. I would like to be
: able to say <cfif not (len(trim(form.textarea))> You did not enter
: anything!</cfif>, but there will always be this default HTML in the
: textarea. So my question is how do I ues Regular expressions
: (which I know
: next to nothing about) to strip out the default content and check
: for user
: entered content only. I'm sure that other SoEditor users would find this
: useful, or maybe one of you have already done this?
:
: Here is the default code:
:
: <HTML>
: <HEAD>
: <META NAME="GENERATOR" Content="Microsoft DHTML Editing Control">
: <TITLE></TITLE>
: </HEAD>
: <BODY style="FONT-FAMILY: ">
: <DIV>&nbsp;</DIV>
: </BODY>
: </HTML>
:
: Thanks for the help. I really need to learn regEx, can any one
: recommend a
: good book or online tutorial?
:
: -Brook
:
:
: 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm

Reply via email to