zero-length string in RegExp 
Author Message
 zero-length string in RegExp

Hi!

How do I specify the zero-length string in the pattern?

re.Pattern = "(?:()|&)"
or
re.Pattern = "(?:|&)"

By the way, I want to replace the control's value in the HTTP query string.
What is the best pattern for that?

My example: "(?:|&)sort_by=(?=.*)(?:|&)"

Adnan



Mon, 12 Jan 2004 00:22:41 GMT  
 zero-length string in RegExp

Quote:
> How do I specify the zero-length string in the pattern?

Could you give an example on the string and the position you are interested
in ?

Best regards
Johnny Nielsen



Mon, 12 Jan 2004 08:31:26 GMT  
 zero-length string in RegExp
Hi!

Here is an example of the string:

http://localhost/xyz/search/?qry=text&sort_by=rank&so=adc

Now, I would like to sort by order and I want to change the value of sort_by
to title or something else. I read the Request.QueryString collection to get
the HTTP query string.

' It returns everything that comes after the "?".
strQry = Request.QueryString

My idea was to specify something like this

re.Pattern = "(?:|&)sort_by=(?=.*)(?:|&)"

The "(?=.*)" part will match the value of the sort_by argument. Is this the
best way to do it and how can I specify the zero-length string in the
pattern (the first expression of my "|" (Or) operator).

Adnan


Quote:


> > How do I specify the zero-length string in the pattern?

> Could you give an example on the string and the position you are
interested
> in ?

> Best regards
> Johnny Nielsen



Mon, 12 Jan 2004 15:25:12 GMT  
 zero-length string in RegExp

Quote:
> Here is an example of the string:
> http://localhost/xyz/search/?qry=text&sort_by=rank&so=adc

> Now, I would like to sort by order and I want to change the value of
sort_by
> to title or something else. I read the Request.QueryString collection to
get
> the HTTP query string.

> ' It returns everything that comes after the "?".
> strQry = Request.QueryString

> My idea was to specify something like this

> re.Pattern = "(?:|&)sort_by=(?=.*)(?:|&)"

> The "(?=.*)" part will match the value of the sort_by argument. Is this
the
> best way to do it and how can I specify the zero-length string in the
> pattern (the first expression of my "|" (Or) operator).

Personally I won't use version 5.5 specific functions yet (no problem in
.ASP though since you know the engine available), and would therefore
recommend a solution using the old capture expressions:

Function ReplaceText(sText, sRepl, sPat)
 Dim regEx
 Set regEx = New RegExp
 regEx.Pattern = sPat
 regEx.IgnoreCase = False
 regEx.Global = True
 ReplaceText = regEx.Replace(sText, sRepl)
End Function

Dim s

s = "http://localhost/xyz/search/?qry=text&sort_by=rank&so=adc"

s = ReplaceText(s, "&sort_by=title", "&sort_by=[^&]*")
s = ReplaceText(s, "&so=something", "&so=[^&]*")

MsgBox s

Best regards
Johnny Nielsen



Tue, 13 Jan 2004 09:10:40 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Zero length strings

2. zero-length strings

3. Allow Zero Length String in a field using SQL

4. Convert Zero-Length String to Null

5. Replace Function returns Nothing instead of Zero-length string

6. ADO - zero length strings

7. Nulls / Zero Length Strings -Newbie Question

8. Newbie Question - Nulls vs zero length strings ???

9. Help please, with Zero-Length String !!

10. Zero Length String error

11. Zero length strings

12. Zero length strings not allowed

 

 
Powered by phpBB® Forum Software