Help...Finding white-space with RegExp 
Author Message
 Help...Finding white-space with RegExp

I am trying to use RegExp to search through a form and replace all of the
double carriage returns with "<p>" tags.

Take a look at my code below.

Thanks
Andy
-------------------------------------------------------
Dim str
dim sTitle, sBody, sDept, sEditor, sIsLive
dim UserID, sBlurb

 sTitle = Request.Form("title")
 sBody = trim(Request.Form("body"))
 sDept = Request.Form("dept")
 sEditor = Request.Form("editor")
 sIsLive = Request.Form("bIsLive")

Dim objRegExp
Set objRegExp = New RegExp
str = sBody
objRegExp.IgnoreCase = True
objRegExp.Global = True

'This will not work
objRegExp.Pattern = "\r"   'Matches a carrage return
str = objRegExp.Replace(str, "This will not")

'This will work
objRegExp.Pattern = "\byippy\b"
str = objRegExp.Replace(str, "This will work")

Set objRegExp = Nothing        'Clean up!

Response.Write(str)



Wed, 19 Nov 2003 03:56:14 GMT  
 Help...Finding white-space with RegExp
from MSDN docs
\cx Matches the control character indicated by x. For example, \cM matches a
Control-M or carriage return character. The value of x must be in the range
of A-Z or a-z. If not, c is assumed to be a literal 'c' character.
\f Matches a form-feed character. Equivalent to \x0c and \cL.
\n Matches a newline character. Equivalent to \x0a and \cJ.
\r Matches a carriage return character. Equivalent to \x0d and \cM.
\s Matches any whitespace character including space, tab, form-feed, etc.
Equivalent to [\f\n\r\t\v].
\S Matches any non-whitespace character. Equivalent to [^ \f\n\r\t\v].
\t Matches a tab character. Equivalent to \x09 and \cI.
\v Matches a vertical tab character. Equivalent to \x0b and \cK.

in JScript it would be var strng.replace(/\r/g,"<BR><BR>");
a VBS newbie (me) would try
Replace(strng,\r,"<BR><BR>")
It will be easier to use 2 break tags rather than enclosing it in a P tag.
If you have to try putting the lines into an array processing them there
in JScript: strng.split("\r"); r[0]="<P>"+r[0]+"</P>";etc


Quote:
> I am trying to use RegExp to search through a form and replace all of the
> double carriage returns with "<p>" tags.

> Take a look at my code below.

> Thanks
> Andy
> -------------------------------------------------------
> Dim str
> dim sTitle, sBody, sDept, sEditor, sIsLive
> dim UserID, sBlurb

>  sTitle = Request.Form("title")
>  sBody = trim(Request.Form("body"))
>  sDept = Request.Form("dept")
>  sEditor = Request.Form("editor")
>  sIsLive = Request.Form("bIsLive")

> Dim objRegExp
> Set objRegExp = New RegExp
> str = sBody
> objRegExp.IgnoreCase = True
> objRegExp.Global = True

> 'This will not work
> objRegExp.Pattern = "\r"   'Matches a carrage return
> str = objRegExp.Replace(str, "This will not")

> 'This will work
> objRegExp.Pattern = "\byippy\b"
> str = objRegExp.Replace(str, "This will work")

> Set objRegExp = Nothing        'Clean up!

> Response.Write(str)



Wed, 19 Nov 2003 10:57:12 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Space Space Space Space Space Space Space

2. Space Space Space Space Space Space Space

3. Space Space Space Space Space Space Space

4. Can not find help about RegExp.

5. white space in IE browser

6. White space preservation in Designmode editor

7. Cropping white vertical space of eps file

8. How do I clear a variable from white spaces

9. White Spaces?

10. RegExp whitespace matching

11. 255 code - white space?

12. How can I convert White space ...

 

 
Powered by phpBB® Forum Software