Regular epressions with .net forward slash "/" character

  • Thread starter Thread starter Lorne Bonnell
  • Start date Start date
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
 
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" )
 
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
 
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... ;)
 
Back
Top