Regular epressions with .net forward slash "/" character

L

Lorne Bonnell

Afternoon all,

Can somone help with this regular expression problem VB sample below
Dim RegexObj As Regex = New Regex("")

RegexObj.IsMatch( "<start field=fred col=2 />", "\x2f" )

Returns false with no match.

This is a simplified example trying to end my capture onthe "/>" but the
forward slash seems not be working.

Thanks
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

No it doesn't. The code you show doesn't even compile. The IsMatch
method is a static method and can't be called using an instantiated object.

This code returns true:

Regex.IsMatch( "<start field=fred col=2 />", "\x2f" )
 
A

alantolan

Actually it does compile - though I personally prefer that it didn't


It's a pet peeve of mine with the language. You can call a static
member of a class by refering to an instance of the class.

RegexObj.IsMatch("<start field=fred col=2 />", "\x2f")

is functionally the same as

Regex.IsMatch( "<start field=fred col=2 />", "\x2f" )


As to the OP's question. I'm afraid that for me I get TRUE (whether
running against the object or class).


typo somewhere?


Alan
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

I see. In C# it's not allowed.

It's a bit more demanding in that way. You actually need to have a small
clue about what you are doing... ;)
 
A

alantolan

Not much of a disagreement, as I said, it is a 'feature' that really
annoys me.

Alan.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top