Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RegExp - Anyone translate from Javascript to ASP (VBScript)?

Status
Not open for further replies.

starblood

Technical User
Feb 28, 2001
63
GB
I have a Javascript Regular Expression working to locate two or more consecutive '<BR>' tags in a string. Trouble is (for various reasons) it isn't a great solution to do it client side - can anyone translate this to work in ASP (VBScript) - I ahve had a go and can't get it to work:

var HasItGotBreaks = StringName.match(/((<br>\s+)|(<br>)){2,}/gi);
 
Is the task really as simple as locating two consecutive break tags?

If so the following should work fine:

Code:
blnHasItGotBreaks = Instr(1,UCase(StringName),"<BR><BR>")>0
 
Cheers for the reply Neil. The task isn't that simple unfortunately:

*The '<BR>' tags could have white space inbetween them (hence the \s+ in my Javascript example)
*I'm looking for AT LEAST two consecutive examples not an EXACT match
*It can't be case sensitive

The Javascript sample quoted does the trick - but I need it server side.
 
This should work:
(untested)

Code:
Dim oRE

Set oRE = New RegExp
oRE.Global = True
oRE.IgnoreCase = True
oRE.Pattern = "((<br>\s+)|(<br>)){2,}"

HasItGotBreaks = oRE.Test(StringName)

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Cheers TomThumbKP - that was just the ticket. Top notch!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top