I probed 5.5 and 5.6 versions and the script showed 0
matches, but I think all is right and the number of
matches would be 1
what's wrong ?
tia

<%@ LANGUAGE=VBScript %>
<%
num = "279"

Set regEx = New RegExp
regEx.Pattern = "/\d{1,3}/"
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(num)
response.write("matches=" & Matches.Count
& "<br>")
Set regEx = Nothing

%>

Re: what's wrong ? (regular expression - vbscript) by Michael

Michael
Wed Oct 22 21:56:45 CDT 2003

anonymous wrote:
> I probed 5.5 and 5.6 versions and the script showed 0
> matches, but I think all is right and the number of
> matches would be 1
> what's wrong ?
> <%@ LANGUAGE=VBScript %>
> <%
> num = "279"
>
> Set regEx = New RegExp
> regEx.Pattern = "/\d{1,3}/"


regEx.Pattern = "\d{1,3}"


> regEx.IgnoreCase = True
> regEx.Global = True
> Set Matches = regEx.Execute(num)
> response.write("matches=" & Matches.Count
> & "<br>")
> Set regEx = Nothing
>
> %>

--
Michael Harris
Microsoft.MVP.Scripting

Windows 2000 Scripting Guide
Microsoft® Windows®2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp

TechNet Script Center Sample Scripts
http://www.microsoft.com/downloads/release.asp?ReleaseID=38942

WSH 5.6 documentation download
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en


Re: what's wrong ? (regular expression - vbscript) by Han

Han
Thu Oct 23 00:05:43 CDT 2003

Predictable result because the target string doesn't have slash which exists
in the pattern.

"anonymous" <anonymous@discussions.microsoft.com> wrote in message
news:05c601c398fc$4d21ff00$a301280a@phx.gbl...
> I probed 5.5 and 5.6 versions and the script showed 0
> matches, but I think all is right and the number of
> matches would be 1
> what's wrong ?
> tia
>
> <%@ LANGUAGE=VBScript %>
> <%
> num = "279"
>
> Set regEx = New RegExp
> regEx.Pattern = "/\d{1,3}/"
> regEx.IgnoreCase = True
> regEx.Global = True
> Set Matches = regEx.Execute(num)
> response.write("matches=" & Matches.Count
> & "<br>")
> Set regEx = Nothing
>
> %>



Re: what's wrong ? (regular expression - vbscript) by anonymous

anonymous
Thu Oct 23 03:53:45 CDT 2003

Hi Michael,
regEx.Pattern =3D "/[0-9]{1,3}/" is not valid and I don't=20
find any valid pattern. Can you help me?

According to http://msdn.microsoft.com/library/default.asp?
URL=3D/library/en-us/dnclinic/html/scripting051099.asp

Character Classes
Character classes enable customized grouping by putting=20
expressions within [] braces. A negated character class=20
may be created by placing ^ as the first character inside=20
the []. Also, a dash can be used to relate a scope of=20
characters. For example, the regular expression "[^a-zA-Z0-
9]" matches everything except alphanumeric characters. In=20
addition, some common character sets are bundled as an=20
escape plus a letter.

Symbol Function=20
[xyz] Match any one character enclosed in the character=20
set.

"[a-e]" matches "b" in "basketball". =20
[^xyz] Match any one character not enclosed in the=20
character set.

"[^a-e]" matches "s" in "basketball". =20
. Match any character except \n. =20
\w Match any word character. Equivalent to [a-zA-Z_0-9]. =20
\W Match any non-word character. Equivalent to [^a-zA-Z_0-
9]. =20

\d Match any digit. Equivalent to [0-9]. =20

\D Match any non-digit. Equivalent to [^0-9]. =20
\s Match any space character. Equivalent to [=20
\t\r\n\v\f]. =20
\S Match any non-space character. Equivalent to [^=20
\t\r\n\v\f]. =20

Repetition
Repetition allows multiple searches on the clause within=20
the regular expression. By using repetition matching, we=20
can specify the number of times an element may be repeated=20
in a regular expression.

Symbol Function=20
{x} Match exactly x occurrences of a regular expression.

"\d{5}" matches 5 digits. =20
(x,} Match x or more occurrences of a regular expression.

"\s{2,}" matches at least 2 space characters. =20
{x,y} Matches x to y number of occurrences of a regular=20
expression.

"\d{2,3}" matches at least 2 but no more than 3 digits. =20
? Match zero or one occurrences. Equivalent to {0,1}.

"a\s?b" matches "ab" or "a b". =20
* Match zero or more occurrences. Equivalent to {0,}. =20
+ Match one or more occurrences. Equivalent to {1,}. =20

>-----Original Message-----
>anonymous wrote:
>> I probed 5.5 and 5.6 versions and the script showed 0
>> matches, but I think all is right and the number of
>> matches would be 1
>> what's wrong ?
>> <%@ LANGUAGE=3DVBScript %>
>> <%
>> num =3D "279"
>>
>> Set regEx =3D New RegExp
>> regEx.Pattern =3D "/\d{1,3}/"
>
>
> regEx.Pattern =3D "\d{1,3}"
>
>
>> regEx.IgnoreCase =3D True
>> regEx.Global =3D True
>> Set Matches =3D regEx.Execute(num)
>> response.write("matches=3D" & Matches.Count
>> & "<br>")
>> Set regEx =3D Nothing
>>
>> %>
>
>--=20
>Michael Harris
>Microsoft.MVP.Scripting
>
>Windows 2000 Scripting Guide
>Microsoft=AE Windows=AE2000 Scripting Guide
>http://www.microsoft.com/technet/scriptcenter/scrguide/sag
sas_overview.asp
>
>TechNet Script Center Sample Scripts
>http://www.microsoft.com/downloads/release.asp?
ReleaseID=3D38942
>
>WSH 5.6 documentation download
>http://www.microsoft.com/downloads/details.aspx?
FamilyId=3D01592C48-207D-4BE1-8A76-
1C4099D7BBB9&displaylang=3Den
>
>.
>

Re: what's wrong ? (regular expression - vbscript) by anonymous

anonymous
Thu Oct 23 04:33:03 CDT 2003

Look at the bottom of
http://www.4guysfromrolla.com/webtech/031500-1.shtml

>-----Original Message-----
>Predictable result because the target string doesn't have
slash which exists
>in the pattern.
>
>"anonymous" <anonymous@discussions.microsoft.com> wrote
in message
>news:05c601c398fc$4d21ff00$a301280a@phx.gbl...
>> I probed 5.5 and 5.6 versions and the script showed 0
>> matches, but I think all is right and the number of
>> matches would be 1
>> what's wrong ?
>> tia
>>
>> <%@ LANGUAGE=VBScript %>
>> <%
>> num = "279"
>>
>> Set regEx = New RegExp
>> regEx.Pattern = "/\d{1,3}/"
>> regEx.IgnoreCase = True
>> regEx.Global = True
>> Set Matches = regEx.Execute(num)
>> response.write("matches=" & Matches.Count
>> & "<br>")
>> Set regEx = Nothing
>>
>> %>
>
>
>.
>

Re: what's wrong ? (regular expression - vbscript) by anonymous

anonymous
Thu Oct 23 04:37:12 CDT 2003

Thanks Han,
I'm a perl programmer and I have a mix of ideas.


>-----Original Message-----
>Predictable result because the target string doesn't have
slash which exists
>in the pattern.
>
>"anonymous" <anonymous@discussions.microsoft.com> wrote
in message
>news:05c601c398fc$4d21ff00$a301280a@phx.gbl...
>> I probed 5.5 and 5.6 versions and the script showed 0
>> matches, but I think all is right and the number of
>> matches would be 1
>> what's wrong ?
>> tia
>>
>> <%@ LANGUAGE=VBScript %>
>> <%
>> num = "279"
>>
>> Set regEx = New RegExp
>> regEx.Pattern = "/\d{1,3}/"
>> regEx.IgnoreCase = True
>> regEx.Global = True
>> Set Matches = regEx.Execute(num)
>> response.write("matches=" & Matches.Count
>> & "<br>")
>> Set regEx = Nothing
>>
>> %>
>
>
>.
>

Re: what's wrong ? (regular expression - vbscript) by anonymous

anonymous
Thu Oct 23 04:41:16 CDT 2003

Sorry Michael,
It's incredible, My brain didn't see two slashes in your=20
message.

regEx.Pattern =3D "[0-9]{1,3}"

Many years working with perl.

>-----Original Message-----
>Hi Michael,
>regEx.Pattern =3D "/[0-9]{1,3}/" is not valid and I don't=20
>find any valid pattern. Can you help me?
>
>According to=20
http://msdn.microsoft.com/library/default.asp?
>URL=3D/library/en-us/dnclinic/html/scripting051099.asp
>
>Character Classes
>Character classes enable customized grouping by putting=20
>expressions within [] braces. A negated character class=20
>may be created by placing ^ as the first character inside=20
>the []. Also, a dash can be used to relate a scope of=20
>characters. For example, the regular expression "[^a-zA-
Z0-
>9]" matches everything except alphanumeric characters. In=20
>addition, some common character sets are bundled as an=20
>escape plus a letter.
>
>Symbol Function=20
>[xyz] Match any one character enclosed in the character=20
>set.
>
>"[a-e]" matches "b" in "basketball". =20
>[^xyz] Match any one character not enclosed in the=20
>character set.
>
>"[^a-e]" matches "s" in "basketball". =20
>.. Match any character except \n. =20
>\w Match any word character. Equivalent to [a-zA-Z_0-
9]. =20
>\W Match any non-word character. Equivalent to [^a-zA-
Z_0-
>9]. =20
>
>\d Match any digit. Equivalent to [0-9]. =20
>
>\D Match any non-digit. Equivalent to [^0-9]. =20
>\s Match any space character. Equivalent to [=20
>\t\r\n\v\f]. =20
>\S Match any non-space character. Equivalent to [^=20
>\t\r\n\v\f]. =20
>
>Repetition
>Repetition allows multiple searches on the clause within=20
>the regular expression. By using repetition matching, we=20
>can specify the number of times an element may be=20
repeated=20
>in a regular expression.
>
>Symbol Function=20
>{x} Match exactly x occurrences of a regular expression.
>
>"\d{5}" matches 5 digits. =20
>(x,} Match x or more occurrences of a regular expression.
>
>"\s{2,}" matches at least 2 space characters. =20
>{x,y} Matches x to y number of occurrences of a regular=20
>expression.
>
>"\d{2,3}" matches at least 2 but no more than 3 digits. =20
>? Match zero or one occurrences. Equivalent to {0,1}.
>
>"a\s?b" matches "ab" or "a b". =20
>* Match zero or more occurrences. Equivalent to {0,}. =20
>+ Match one or more occurrences. Equivalent to {1,}. =20
>
>>-----Original Message-----
>>anonymous wrote:
>>> I probed 5.5 and 5.6 versions and the script showed 0
>>> matches, but I think all is right and the number of
>>> matches would be 1
>>> what's wrong ?
>>> <%@ LANGUAGE=3DVBScript %>
>>> <%
>>> num =3D "279"
>>>
>>> Set regEx =3D New RegExp
>>> regEx.Pattern =3D "/\d{1,3}/"
>>
>>
>> regEx.Pattern =3D "\d{1,3}"
>>
>>
>>> regEx.IgnoreCase =3D True
>>> regEx.Global =3D True
>>> Set Matches =3D regEx.Execute(num)
>>> response.write("matches=3D" & Matches.Count
>>> & "<br>")
>>> Set regEx =3D Nothing
>>>
>>> %>
>>
>>--=20
>>Michael Harris
>>Microsoft.MVP.Scripting
>>
>>Windows 2000 Scripting Guide
>>Microsoft=AE Windows=AE2000 Scripting Guide
>>http://www.microsoft.com/technet/scriptcenter/scrguide/sa
g
>sas_overview.asp
>>
>>TechNet Script Center Sample Scripts
>>http://www.microsoft.com/downloads/release.asp?
>ReleaseID=3D38942
>>
>>WSH 5.6 documentation download
>>http://www.microsoft.com/downloads/details.aspx?
>FamilyId=3D01592C48-207D-4BE1-8A76-
>1C4099D7BBB9&displaylang=3Den
>>
>>.
>>
>.
>