Question

Onload Find/Replace (null) in Text fields

Asked by: trailerman

I need to fix the last function of my existing script.  It currently performs a find/replace function
of <BR> and carriage returns.  They work fine, and my only help needed is as follows
and again related to last js function:

It is looking for the '(null)'  value and it does find it, but it replaces it with "()"

what do I have to change (only in last js function), so it removes/deletes
the entire value ( paranthesis and the null)?

thanks.

Thank you.

<HTML>HEAD>TITLE>task.htm/TITLE>

  <SCRIPT LANGUAGE="JavaScript">
   <!--
   function makeonelineineverytextarea() {
   var regexCRLF = new RegExp( '/r/n', 'g' )
   var ec = document.forms[0].elements.length - 1;
   var element = document.forms[0].elements;
   for (i= 0; i <= ec; i ++) {
    //alert('elemnt('+i+'): '+element[i].type)
    if (element[i].type == 'textarea') element[i].value = element[i].value.replace(regexCRLF, '<br>')
   }
   }
   function makemultylineineverytextarea() {
   var regexBR = new RegExp( '<BR>', 'gi' )
   var ec = document.forms[0].elements.length - 1;
   var element = document.forms[0].elements;
   for (i= 0; i <= ec; i ++) {
    if (element[i].type == 'textarea') element[i].value = element[i].value.replace(regexBR, '\r\n')
   }
   }
   function makemultylineineverytextarea() {
   var regexBR = new RegExp( '(null)', 'gi' )
   var ec = document.forms[0].elements.length - 1;
   var element = document.forms[0].elements;
   for (i= 0; i <= ec; i ++) {
   if (element[i].type == 'textarea') element[i].value = element[i].value.replace(regexBR, '')
   if (element[i].type == 'text') element[i].value = element[i].value.replace(regexBR, '')
   if (element[i].type == 'hidden') element[i].value = element[i].value.replace(regexBR, '')
  }
  }
   // -->
</SCRIPT>
BODY BGCOLOR="#FFFFFF" LINK="#CC0000" ALINK="#00CC00" VLINK="#CC0000" onLoad="makemultylineineverytextarea()">
P>FORM ACTION="/cgi-bin/sql/update.cgi" METHOD=POST>
CENTER>INPUT TYPE=hidden NAME=template VALUE="staff/back.htm">
INPUT TYPE=hidden NAME="ID_field" VALUE="tasks.tasks_ID">
INPUT TYPE=hidden NAME="ID_value" VALUE="{{tasks.tasks_ID}}">
INPUT TYPE=hidden NAME="tasks.date_updated" VALUE="system_date">
INPUT TYPE=hidden NAME="tasks.name_updated" VALUE="{{tasks.staff_name}}">
H3>CENTER>Update Tasks /CENTER>/H3>
FONT SIZE="-1" FACE="Arial, Helvetica">
table cellspacing=2 cellpadding=0 width="80%">
tr> td height="25"> FONT SIZE="-1" FACE="Verdana">Title: /FONT>
/TD>td height="25">
FONT SIZE="-1" FACE="Verdana">P>input type=text name="tasks.tasks_title" size=25 maxlength=100>/FONT>
/TD>
/TR>
tr>td height="18">FONT SIZE="-1" FACE="Verdana">Category: /FONT>
/TD>
td height="18">
FONT SIZE="-1" FACE="Verdana">input type=text name="tasks.category" size=25 maxlength=100>
/FONT>
/TD>
/TR>
tr>
td>
FONT SIZE="-1" FACE="Verdana"> Notes

/td>td>P>textarea rows=3 cols=35 wrap="soft" name="tasks.note">/TEXTAREA>
/TD>/TR>
/TABLE>
INPUT TYPE=submit VALUE="Submit" onClick="makeonelineineverytextarea()"> P>
/FONT>/CENTER>
/FORM>
/TD>
/TR>
/TABLE>
 /FONT>
/BODY>
/HTML>

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2001-07-30 at 18:27:39ID20160578
Tags

null

Topics

JavaScript

,

Font Creator

Participating Experts
4
Points
300
Comments
27

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Excute CGI onLoad
    Hi, I made a small (Text-Based) Counter using Delphi cgi .. Please tell me How I excute it in my index.htm file .. is there a special HTML tag or what ??!!! Note : I Want to get TEXT-BASED Counter
  2. Storing RegExp matches in an array
    Hi, I have a strange problem when trying to remember RegExp matches in an array. Below is an example which shows it. If the search pattern matches something it's OK, but if it matches nothing i get error message. In this case, if you comment the line var myvar=.. and uncom...
  3. RegExp problem
    Hi, this is probably an easy one, but I just don't seem to get it right. I'm trying to validate decimal input by using the RegExp object. When I define my pattern as a 'constant' inside my code, it doesn't seem to work, although the same pattern works just fine when I ent...
  4. RegExp for PO Box validation
    I am trying to find a one-line solution for using RegExp to validate the syntax of an address field. I do not want to allow PO Box entries. Here is what I have been attempting, I just haven't been able to find the right combination. (this is just testing code) //var r...
  5. regexp for replacing  '
    // how to write ' to regexp ? tmp= parent.frames[1].document.getElementById('noPass'); if(tmp!=null){ re = new RegExp("type='text''","gi"); str = new String(tmp.innerHTML); str=str.replace(re, "type='password'"); tmp.innerHTML= str; }

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: coreytiPosted on 2001-07-30 at 23:29:09ID: 6336779

Seems to me that you need to add a call to your other function to your onload statement so that you have:

----------
onLoad="makeonelineineverytextarea(); makemultylineineverytextarea()"
----------

and you should change both for loops from:

----------
for (i= 0; i = ec; i ++)
----------

to

----------
// less than
for (i= 0; i < ec; i ++)
----------


-corey

 

by: trailermanPosted on 2001-07-31 at 09:04:08ID: 6337857

Should the both onload fuctions be named the same?... what do you mean should add another call function.  How will it know to pullout "(null)" value?

 

by: owlseyPosted on 2001-07-31 at 09:12:54ID: 6337874

name them seperately- just call both function with the onload

 

by: pjttPosted on 2001-07-31 at 09:38:38ID: 6337949

Are you just trying to search the form elements or the HTML too? Searching the form elements would be easy, just add another reg exp that looks for "null" - searching the HTML would be tricky though. You should check for null values before you send stuff to the client, not after.

If you still want to, well here's an IE/NS6 solution. Make sure you give every element an ID or a name. Load the entire HTML, searching for occurances of <[.\n]*null - that's the "<" character, and number of characters, and then "null". The reason you search for "<" is because you want to access the last tag before the word null. Then back up in the string to find the ID of that tag, and then you can just replace the text there. Otherwise you can do

for (var i=0; document.all[i]; i++) //look for "null" and replace it here

use this code to get document.all in NS6:

function getAllCollection() {
     if (typeof(document.getElementsByTagName) == "function" && document.getElementsByTagName("*")) {
        document.all = document.getElementsByTagName("*")
     }
}
if (!document.all) getAllCollection();


It's probably possible to do it in browsers other than IE4+/NS6, but far more complicated.

Peter Tracey
Developer
http://www.25online.com/peter

 

by: coreyitPosted on 2001-08-01 at 02:39:24ID: 6339706

as owlsey stated, what I mean is for you to "call" (run) both functions ( makeonelineineverytextarea() and makemultylineineverytextarea() ) from the same onload event in your body tag.

once that is done, be sure to correct the "for" loops so they run as long as the counter is less-than the number of form elements (will cover every element and then stop).

-corey

 

by: trailermanPosted on 2001-08-01 at 07:53:59ID: 6340816

pjtt , I wanted to search all textfields and textareas (hidden or not) to delete all "null" values, and do this onload in cunjunction with other javascript function in above script. here are the area and fields types for example:

input type="text" value=null
input type="textarea" value=null
input type="hidden" value=null

so best to write any function, that searches where value = or includes "null" value, would you agree?

I don't understand javascript formatting so please send me complete modified javascript or better the entire html.
thank you...

 

by: pjttPosted on 2001-08-01 at 10:37:02ID: 6341409

I wrote a function formFindReplace() that takes a string to search for, a string to replace it with, and a form object. Onload initialize() is called, which does the replaces for new lines and nulls. I noticed you only have text elements and no selects, checkboxes, etc. on your form, so I only coded for those (though I did allow for the possibility of multiple textboxes with the same name). If you add other elements you'll have to check either the name or the type of the element before you try to run the replace method.

<SCRIPT LANGUAGE="JavaScript">
!--

function initialize() {
     var f = document.forms[0];
     formFindReplace(/\r\n/g, "<br>", f) // finds occurances of carraige-return line-feed
     formFindReplace(/[\r\n]/g, "<br>", f) // find occurances of either one alone
     formFindReplace("null", "", f) // find occurances of either one alone
}

function formFindReplace(Find, sReplace, f) {
     for (var i=0; i<f.elements.length; i++) {
          if (f.elements[i].length) {
               for (var j=0; j<f.elements[i].length; j++) {
                    f.elements[i][j].value = f.elements[i][j].value.replace(Find, sReplace);
               }
          } else {
               f.elements[i].value = f.elements[i].value.replace(Find, sReplace);
          }
     }
}

// -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#CC0000" ALINK="#00CC00" VLINK="#CC0000" onLoad="initialize()">



Hope this helps!!

Peter Tracey
Developer
http://www.25online.com/peter

 

by: trailermanPosted on 2001-08-01 at 12:01:26ID: 6341801

pji and others:

Isimplified(modified) the question, as I need to work with existing script. Please see, I don't know java script so I simply need someone to tell me how to write code properly per revised question.

thanks

 

by: pjttPosted on 2001-08-01 at 12:08:16ID: 6341835

The code I gave you does exactly what you want.

Peter Tracey
Developer
http://www.25online.com/peter

 

by: pjttPosted on 2001-08-01 at 12:10:09ID: 6341843

here's a modified version that checkes the type of the element before doing the replace:

function formFindReplace(Find, sReplace, f) {
    if (f.elements[i].type != "text" && f.elements[i].type != "textarea" && f.elements[i].type != "hidden") continue;
    for (var i=0; i<f.elements.length; i++) {
         if (f.elements[i].length) {
              for (var j=0; j<f.elements[i].length; j++) {
                   f.elements[i][j].value = f.elements[i][j].value.replace(Find, sReplace);
              }
         } else {
              f.elements[i].value = f.elements[i].value.replace(Find, sReplace);
         }
    }
}

 

by: pjttPosted on 2001-08-01 at 12:10:59ID: 6341846

Oops:

function formFindReplace(Find, sReplace, f) {
   for (var i=0; i<f.elements.length; i++) {
      if (f.elements[i].type != "text" && f.elements[i].type != "textarea" && f.elements[i].type != "hidden")
continue;
        if (f.elements[i].length) {
             for (var j=0; j<f.elements[i].length; j++) {
                  f.elements[i][j].value = f.elements[i][j].value.replace(Find, sReplace);
             }
        } else {
             f.elements[i].value = f.elements[i].value.replace(Find, sReplace);
        }
   }
}

 

by: trailermanPosted on 2001-08-01 at 12:21:24ID: 6341884

I can't yours to work..(not saying it doesn't on your end), I'm just looking for answer to the "(null)" element, can you help?  thanks much.

 

by: pjttPosted on 2001-08-01 at 12:31:21ID: 6341923

Here's the complete HTML for my solution.

If you still can't get it to work... to replace null just copy the reg exp I'm using in there: ((new RegExp("null", "g"))

The problem with your updated page is that you have two functions with the same name, so it's just chosing one to run (either the first or the last, I'm not sure). Try my code first though because it's much cleaner.

Peter Tracey
Developer
http://www.25online.com/peter


<HTML><HEAD><TITLE>task.htm</TITLE>

<SCRIPT LANGUAGE="JavaScript">
!--

function initialize() {
     var f = document.forms[0];
     formFindReplace(/\r\n/g, "<br>", f) // finds occurances of carraige-return line-feed
     formFindReplace(/[\r\n]/g, "<br>", f) // find occurances of either one alone
     formFindReplace((new RegExp("null", "g")), "", f) // find occurances of either one alone
}

function formFindReplace(Find, sReplace, f) {
     for (var i=0; i<f.elements.length; i++) {
          if (f.elements[i].type != "text" && f.elements[i].type != "textarea" && f.elements[i].type != "hidden") continue;
          if (f.elements[i].length) {
               for (var j=0; j<f.elements[i].length; j++) {
                    f.elements[i][j].value = f.elements[i][j].value.replace(Find, sReplace);
               }
          } else {
               f.elements[i].value = f.elements[i].value.replace(Find, sReplace);
          }
     }
}

// -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#CC0000" ALINK="#00CC00" VLINK="#CC0000" onLoad="initialize()">
<P><FORM ACTION="/cgi-bin/sql/update.cgi" METHOD=POST>
<CENTER><INPUT TYPE=hidden NAME=template VALUE="staff/back.htm">
<INPUT TYPE=hidden NAME="ID_field" VALUE="tasks.tasks_ID">
<INPUT TYPE=hidden NAME="ID_value" VALUE="{{tasks.tasks_ID}}">
<INPUT TYPE=hidden NAME="tasks.date_updated" VALUE="system_date">
<INPUT TYPE=hidden NAME="tasks.name_updated" VALUE="{{tasks.staff_name}}">
<H3><CENTER>Update Tasks </CENTER></H3>
<FONT SIZE="-1" FACE="Arial, Helvetica">
<table cellspacing=2 cellpadding=0 width="80%">
<tr> <td height="25"> <FONT SIZE="-1" FACE="Verdana">Title: </FONT>
</TD><td height="25">
<FONT SIZE="-1" FACE="Verdana"><P><input type=text name="tasks.tasks_title" size=25 maxlength=100></FONT>
</TD>
</TR>
<tr><td height="18"><FONT SIZE="-1" FACE="Verdana">Category: </FONT>
</TD>
<td height="18">
<FONT SIZE="-1" FACE="Verdana"><input type=text name="tasks.category" size=25 maxlength=100>
</FONT>
</TD>
</TR>
<tr>
<td>
<FONT SIZE="-1" FACE="Verdana"> Notes

</td><td><P><textarea rows=3 cols=35 wrap="soft" name="tasks.note">nullnullnull</TEXTAREA>
</TD></TR>
</TABLE>
<INPUT TYPE=submit VALUE="Submit" onClick="makeonelineineverytextarea()"> <P>
</FONT></CENTER>
</FORM>
</TD>
</TR>
</TABLE>
</FONT>
</BODY>
</HTML>

 

by: trailermanPosted on 2001-08-01 at 12:36:13ID: 6341950

thanks anyway... I figured it out with the use of' [(null)]'

Your java skills are good, I'm sure, but just needed a quick answer to my modification
 question. thanks for the effort anyway.

 

by: pjttPosted on 2001-08-01 at 12:38:19ID: 6341960

[(null)] is a character set... you're going to get very unexpected results even though it seems to work in your test.

 

by: pjttPosted on 2001-08-01 at 12:39:13ID: 6341963

...It'll replace any occurance of "n", "u", or "l"

 

by: trailermanPosted on 2001-08-01 at 13:16:09ID: 6342115

yes, you're right. the [] takes out the "n" from the Name=   value.

So what can I do to constrain it from just pulling out the '(null)'  and
not messing with anything else.  is there another way to express
the '(' and ')" on both sides of the null.

respectly resumbitting question to you pjit

 

by: pjttPosted on 2001-08-01 at 13:17:42ID: 6342123

...It'll replace any occurance of "n", "u", or "l"

 

by: pjttPosted on 2001-08-01 at 13:23:58ID: 6342149

The "(" and ")" characters have meaning in regular expressions, so you have to escape them with "\".

new RegExp("\(null\)", "g")

will replace any occurance of "(null)".

or if you also want to replace it if it doesn't have the () then:

new RegExp("\(?null\)?", "g")

will replace any occurance of "(null)" or "null"

I wrote an XML parser in JavaScript based on regular expressions (jsxml.homestead.com) so I'm good with them.

Here's the complete guide (from M$) to JavaScript regular expression syntax.

Peter Tracey
Developer
http://www.25online.com/peter

<TABLE WIDTH=87% BORDER=1 CELLPADDING=5 CELLSPACING=0>
<TR VALIGN=TOP BGCOLOR="#DDDDDD">
<TD><FONT SIZE=2><b>Character</b></FONT></TD>
<TD><FONT SIZE=2><b>Description</b></FONT></TD></TR>
<tr valign=top>
<td><font size=2><b>\</b> </font></td>
<td><font size=2>Marks the next character as either a special character or a literal. For example, "n" matches the character "n". "\n" matches a newline character. The sequence "\\" matches "\" and "\(" matches "(".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>^</b> </font></td>
<td><font size=2>Matches the beginning of input.</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>$</b> </font></td>
<td><font size=2>Matches the end of input.</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>*</b> </font></td>
<td><font size=2>Matches the preceding character zero or more times. For example, "zo*" matches either "z" or "zoo".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>+</b> </font></td>
<td><font size=2>Matches the preceding character one or more times. For example, "zo+" matches "zoo" but not "z". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>?</b> </font></td>
<td><font size=2>Matches the preceding character zero or one time. For example, "a?ve?" matches the "ve" in "never". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>.</b></font></td>
<td><font size=2>Matches any single character except a newline character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>(</b><i>pattern</i><b>)</b> </font></td>
<td><font size=2>Matches <i>pattern</i> and remembers the match. The matched substring can be retrieved from the resulting <b>Matches</b> collection, using Item <b>[0]...[n]</b>. To match parentheses characters ( ), use "\(" or "\)".</font></td>
</tr>
<tr valign=top>
<td><font size=2><i>x</i><b>|</b><i>y</i></font></td>
<td><font size=2>Matches either <i>x</i> or <i>y</i>. For example, "z|food" matches "z" or "food". "(z|f)ood" matches "zoo" or "food".  </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>{</b><i>n</i><b>}</b></font></td>
<td><font size=2><i>n</i> is a nonnegative integer. Matches exactly <i>n</i> times. For example, "o{2}" does not match the "o" in "Bob," but matches the first two o's in "foooood".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>{</b><i>n</i><b>,}</b> </font></td>
<td><font size=2><i>n</i> is a nonnegative integer. Matches at least <i>n</i> times.  For example, "o{2,}" does not match the "o" in "Bob" and matches all the o's in "foooood". "o{1,}" is equivalent to "o+". "o{0,}" is equivalent to "o*".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>{</b><i>n</i><b>,</b><i>m</i><b>}</b> </font></td>
<td><font size=2><i>m</i> and <i>n</i> are nonnegative integers. Matches at least <i>n</i> and at most <i>m</i> times. For example, "o{1,3}" matches the first three o's in "fooooood". "o{0,1}" is equivalent to "o?".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>[</b><i>xyz</i><b>]</b> </font></td>
<td><font size=2>A character set. Matches any one of the enclosed characters. For example, "[abc]" matches the "a" in "plain". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>[^</b><i>xyz</i><b>]</b> </font></td>
<td><font size=2>A negative character set. Matches any character not enclosed. For example, "[^abc]" matches the "p" in "plain". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>[</b><i>a-z</i><b>]</b> </font></td>
<td><font size=2>A range of characters. Matches any character in the specified range. For example, "[a-z]" matches any lowercase alphabetic character in the range "a" through "z". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>[^</b><i>m-z</i><b>]</b> </font></td>
<td><font size=2>A negative range characters. Matches any character not in the specified range. For example, "[m-z]" matches any character not in the range "m" through "z". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\b</b> </font></td>
<td><font size=2>Matches a word boundary, that is, the position between a word and a space. For example, "er\b" matches the "er" in "never" but not the "er" in "verb". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\B</b> </font></td>
<td><font size=2>Matches a nonword boundary. "ea*r\B" matches the "ear" in "never early". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\d</b> </font></td>
<td><font size=2>Matches a digit character. Equivalent to [0-9]. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\D</b> </font></td>
<td><font size=2>Matches a nondigit character. Equivalent to [^0-9]. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\f</b> </font></td>
<td><font size=2>Matches a form-feed character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\n</b> </font></td>
<td><font size=2>Matches a newline character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\r</b> </font></td>
<td><font size=2>Matches a carriage return character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\s</b> </font></td>
<td><font size=2>Matches any white space including space, tab, form-feed, etc. Equivalent to "[&nbsp;\f\n\r\t\v]".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\S</b> </font></td>
<td><font size=2>Matches any nonwhite space character. Equivalent to "[^&nbsp;\f\n\r\t\v]". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\t</b> </font></td>
<td><font size=2>Matches a tab character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\v</b> </font></td>
<td><font size=2>Matches a vertical tab character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\w</b> </font></td>
<td><font size=2>Matches any word character including underscore. Equivalent to "[A-Za-z0-9_]". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\W</b> </font></td>
<td><font size=2>Matches any nonword character. Equivalent to "[^A-Za-z0-9_]". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\</b><i>num</i> </font></td>
<td><font size=2>Matches <i>num</i>, where <i>num</i> is a positive integer. A reference back to remembered matches. For example, "(.)\1" matches two consecutive identical characters. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\</b><i>n</i></font></td>
<td><font size=2>Matches <i>n</i>, where <i>n</i> is an octal escape value. Octal escape values must be 1, 2, or 3 digits long. For example, "\11" and "\011" both match a tab character. "\0011" is the equivalent of "\001" & "1". Octal escape values must not exceed 256. If they do, only the first two digits comprise the expression.  Allows ASCII codes to be used in regular expressions.</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\x</b><i>n</i></font></td>
<td><font size=2>Matches <i>n</i>, where <i>n</i> is a hexadecimal escape value.  Hexadecimal escape values must be exactly two digits long. For example, "\x41" matches "A". "\x041" is equivalent to "\x04" & "1". Allows ASCII codes to be used in regular expressions.</font></td>
</tr>

</TABLE>

 

by: trailermanPosted on 2001-08-01 at 13:24:09ID: 6342150

so are you saying that there is no answer to my  specific question, and your answer is only possible solution?

 

by: pjttPosted on 2001-08-01 at 13:25:21ID: 6342155

The "(" and ")" characters have meaning in regular expressions, so you have to escape them with "\".

new RegExp("\(null\)", "g")

will replace any occurance of "(null)".

or if you also want to replace it if it doesn't have the () then:

new RegExp("\(?null\)?", "g")

will replace any occurance of "(null)" or "null"

I wrote an XML parser in JavaScript based on regular expressions (jsxml.homestead.com) so I'm good with them.

Here's the complete guide (from M$) to JavaScript regular expression syntax.

Peter Tracey
Developer
http://www.25online.com/peter

<TABLE WIDTH=87% BORDER=1 CELLPADDING=5 CELLSPACING=0>
<TR VALIGN=TOP BGCOLOR="#DDDDDD">
<TD><FONT SIZE=2><b>Character</b></FONT></TD>
<TD><FONT SIZE=2><b>Description</b></FONT></TD></TR>
<tr valign=top>
<td><font size=2><b>\</b> </font></td>
<td><font size=2>Marks the next character as either a special character or a literal. For example, "n" matches the character "n". "\n" matches a newline character. The sequence "\\" matches "\" and "\(" matches "(".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>^</b> </font></td>
<td><font size=2>Matches the beginning of input.</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>$</b> </font></td>
<td><font size=2>Matches the end of input.</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>*</b> </font></td>
<td><font size=2>Matches the preceding character zero or more times. For example, "zo*" matches either "z" or "zoo".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>+</b> </font></td>
<td><font size=2>Matches the preceding character one or more times. For example, "zo+" matches "zoo" but not "z". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>?</b> </font></td>
<td><font size=2>Matches the preceding character zero or one time. For example, "a?ve?" matches the "ve" in "never". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>.</b></font></td>
<td><font size=2>Matches any single character except a newline character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>(</b><i>pattern</i><b>)</b> </font></td>
<td><font size=2>Matches <i>pattern</i> and remembers the match. The matched substring can be retrieved from the resulting <b>Matches</b> collection, using Item <b>[0]...[n]</b>. To match parentheses characters ( ), use "\(" or "\)".</font></td>
</tr>
<tr valign=top>
<td><font size=2><i>x</i><b>|</b><i>y</i></font></td>
<td><font size=2>Matches either <i>x</i> or <i>y</i>. For example, "z|food" matches "z" or "food". "(z|f)ood" matches "zoo" or "food".  </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>{</b><i>n</i><b>}</b></font></td>
<td><font size=2><i>n</i> is a nonnegative integer. Matches exactly <i>n</i> times. For example, "o{2}" does not match the "o" in "Bob," but matches the first two o's in "foooood".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>{</b><i>n</i><b>,}</b> </font></td>
<td><font size=2><i>n</i> is a nonnegative integer. Matches at least <i>n</i> times.  For example, "o{2,}" does not match the "o" in "Bob" and matches all the o's in "foooood". "o{1,}" is equivalent to "o+". "o{0,}" is equivalent to "o*".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>{</b><i>n</i><b>,</b><i>m</i><b>}</b> </font></td>
<td><font size=2><i>m</i> and <i>n</i> are nonnegative integers. Matches at least <i>n</i> and at most <i>m</i> times. For example, "o{1,3}" matches the first three o's in "fooooood". "o{0,1}" is equivalent to "o?".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>[</b><i>xyz</i><b>]</b> </font></td>
<td><font size=2>A character set. Matches any one of the enclosed characters. For example, "[abc]" matches the "a" in "plain". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>[^</b><i>xyz</i><b>]</b> </font></td>
<td><font size=2>A negative character set. Matches any character not enclosed. For example, "[^abc]" matches the "p" in "plain". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>[</b><i>a-z</i><b>]</b> </font></td>
<td><font size=2>A range of characters. Matches any character in the specified range. For example, "[a-z]" matches any lowercase alphabetic character in the range "a" through "z". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>[^</b><i>m-z</i><b>]</b> </font></td>
<td><font size=2>A negative range characters. Matches any character not in the specified range. For example, "[m-z]" matches any character not in the range "m" through "z". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\b</b> </font></td>
<td><font size=2>Matches a word boundary, that is, the position between a word and a space. For example, "er\b" matches the "er" in "never" but not the "er" in "verb". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\B</b> </font></td>
<td><font size=2>Matches a nonword boundary. "ea*r\B" matches the "ear" in "never early". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\d</b> </font></td>
<td><font size=2>Matches a digit character. Equivalent to [0-9]. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\D</b> </font></td>
<td><font size=2>Matches a nondigit character. Equivalent to [^0-9]. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\f</b> </font></td>
<td><font size=2>Matches a form-feed character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\n</b> </font></td>
<td><font size=2>Matches a newline character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\r</b> </font></td>
<td><font size=2>Matches a carriage return character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\s</b> </font></td>
<td><font size=2>Matches any white space including space, tab, form-feed, etc. Equivalent to "[&nbsp;\f\n\r\t\v]".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\S</b> </font></td>
<td><font size=2>Matches any nonwhite space character. Equivalent to "[^&nbsp;\f\n\r\t\v]". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\t</b> </font></td>
<td><font size=2>Matches a tab character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\v</b> </font></td>
<td><font size=2>Matches a vertical tab character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\w</b> </font></td>
<td><font size=2>Matches any word character including underscore. Equivalent to "[A-Za-z0-9_]". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\W</b> </font></td>
<td><font size=2>Matches any nonword character. Equivalent to "[^A-Za-z0-9_]". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\</b><i>num</i> </font></td>
<td><font size=2>Matches <i>num</i>, where <i>num</i> is a positive integer. A reference back to remembered matches. For example, "(.)\1" matches two consecutive identical characters. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\</b><i>n</i></font></td>
<td><font size=2>Matches <i>n</i>, where <i>n</i> is an octal escape value. Octal escape values must be 1, 2, or 3 digits long. For example, "\11" and "\011" both match a tab character. "\0011" is the equivalent of "\001" & "1". Octal escape values must not exceed 256. If they do, only the first two digits comprise the expression.  Allows ASCII codes to be used in regular expressions.</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\x</b><i>n</i></font></td>
<td><font size=2>Matches <i>n</i>, where <i>n</i> is a hexadecimal escape value.  Hexadecimal escape values must be exactly two digits long. For example, "\x41" matches "A". "\x041" is equivalent to "\x04" & "1". Allows ASCII codes to be used in regular expressions.</font></td>
</tr>

</TABLE>

 

by: pjttPosted on 2001-08-01 at 13:29:15ID: 6342162

No, here's the answer:

new RegExp("\(null\)", "gi")


The code you have will work ok if you rename the third function so that it is unique, call all three functions in the onload event (or call the second from the first and the third from the second..), and fix the regular expression with those escape ("\") characters.

The code I gave you, however, is a cleaner solution, you just have to replace "null" with "\(null\)"

Peter Tracey
Developer
http://www.25online.com/peter

 

by: trailermanPosted on 2001-08-01 at 13:32:01ID: 6342174

I use apostrafy not quotes... and can you send me the complete code changes that
you are talking about here is what I have, but still doesn't replace paranthesis, just null portion
of text:

    }
     }
     function makemultylineineverytextarea() {
     var regexBR = new RegExp( '\(null\)', 'gi' )
     var ec = document.forms[0].elements.length - 1;
     var element = document.forms[0].elements;
     for (i= 0; i <= ec; i ++) {
     if (element[i].type == 'textarea') element[i].value = element[i].value.replace(regexBR, '')
     if (element[i].type == 'text') element[i].value = element[i].value.replace(regexBR, '')
     if (element[i].type == 'hidden') element[i].value = element[i].value.replace(regexBR, '')

 

by: pjttPosted on 2001-08-01 at 13:41:28ID: 6342219

No, here's the answer:

new RegExp("\(null\)", "gi")


The code you have will work ok if you rename the third function so that it is unique, call all three functions in the onload event (or call the second from the first and the third from the second..), and fix the regular expression with those escape ("\") characters.

The code I gave you, however, is a cleaner solution, you just have to replace "null" with "\(null\)"

Peter Tracey
Developer
http://www.25online.com/peter

 

by: pjttPosted on 2001-08-01 at 14:03:43ID: 6342304

No, here's the answer:

new RegExp("\(null\)", "gi")


The code you have will work ok if you rename the third function so that it is unique, call all three functions in the onload event (or call the second from the first and the third from the second..), and fix the regular expression with those escape ("\") characters.

The code I gave you, however, is a cleaner solution, you just have to replace "null" with "\(null\)"

Peter Tracey
Developer
http://www.25online.com/peter

 

by: pjttPosted on 2001-08-01 at 14:05:43ID: 6342315

<HTML><HEAD><TITLE>task.htm</TITLE>

<SCRIPT LANGUAGE="JavaScript">
<!--
function makeonelineineverytextarea() {
       var regexCRLF = new RegExp( '/r/n', 'g' )
       var ec = document.forms[0].elements.length - 1;
       var element = document.forms[0].elements;
       for (i= 0; i <= ec; i ++) {
             //alert('elemnt('+i+'): '+element[i].type)
             if (element[i].type == 'textarea') element[i].value = element[i].value.replace(regexCRLF, '<br>')
       }
       makemultylineineverytextarea()
}
function makemultylineineverytextarea() {
       var regexBR = new RegExp( '<BR>', 'gi' )
       var ec = document.forms[0].elements.length - 1;
       var element = document.forms[0].elements;
       for (i= 0; i <= ec; i ++) {
             if (element[i].type == 'textarea') element[i].value = element[i].value.replace(regexBR, '\r\n')
       }
       makenonullsineverytextarea()
}
function makenonullsineverytextarea() {
     var regexBR = new RegExp( '[\(]?null[\)]?', 'gi' )
     var ec = document.forms[0].elements.length - 1;
     var element = document.forms[0].elements;
     for (i= 0; i <= ec; i ++) {
          if (element[i].type == 'textarea') element[i].value = element[i].value.replace(regexBR, '')
          if (element[i].type == 'text') element[i].value = element[i].value.replace(regexBR, '')
          if (element[i].type == 'hidden') element[i].value = element[i].value.replace(regexBR, '')
     }
}
// -->
</SCRIPT>
<BODY BGCOLOR="#FFFFFF" LINK="#CC0000" ALINK="#00CC00" VLINK="#CC0000" onLoad="makemultylineineverytextarea()">
<P><FORM ACTION="/cgi-bin/sql/update.cgi" METHOD=POST>
<CENTER><INPUT TYPE=hidden NAME=template VALUE="staff/back.htm">
<INPUT TYPE=hidden NAME="ID_field" VALUE="tasks.tasks_ID">
<INPUT TYPE=hidden NAME="ID_value" VALUE="{{tasks.tasks_ID}}">
<INPUT TYPE=hidden NAME="tasks.date_updated" VALUE="system_date">
<INPUT TYPE=hidden NAME="tasks.name_updated" VALUE="{{tasks.staff_name}}">
<H3>CENTER>Update Tasks </CENTER></H3>
<FONT SIZE="-1" FACE="Arial, Helvetica">
<table cellspacing=2 cellpadding=0 width="80%">
<tr> <td height="25"> <FONT SIZE="-1" FACE="Verdana">Title: </FONT>
</TD><td height="25">
<FONT SIZE="-1" FACE="Verdana"><P><input type=text name="tasks.tasks_title" size=25 maxlength=100></FONT>
</TD>
</TR>
<tr><td height="18"><FONT SIZE="-1" FACE="Verdana">Category: </FONT>
</TD>
<td height="18">
<FONT SIZE="-1" FACE="Verdana"><input type=text name="tasks.category" size=25 maxlength=100>
</FONT>
</TD>
</TR>
<tr>
<td>
<FONT SIZE="-1" FACE="Verdana"> Notes

</td><td><P><textarea rows=3 cols=35 wrap="soft" name="tasks.note">(null) null asdf (null</TEXTAREA>
</TD></TR>
</TABLE>
<INPUT TYPE=submit VALUE="Submit" onClick="makeonelineineverytextarea()"> <P>
</FONT></CENTER>
</FORM>
</TD>
</TR>
</TABLE>
</FONT>
</BODY>
</HTML>

 

by: trailermanPosted on 2001-08-01 at 14:59:47ID: 6342504

impressive range of java knowledge

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...