How to matching "[" in string

Hi,

How to matching “[” in string with regular expressions?

“[” =~ /[/ – don’t work.

On May 10, 2006, at 4:27 PM, sed_nivo wrote:

Hi,

How to matching “[” in string with regular expressions?

“[” =~ /[/ – don’t work.

Says who? :wink:

“[” =~ /[/ ? “It matched!” : “No match.”
=> “It matched!”

James Edward G. II

On 10-May-06, at 5:27 PM, sed_nivo wrote:

How to matching “[” in string with regular expressions?

“[” =~ /[/ – don’t work.

What do you mean by “don’t work”? What do you expect? Have you read
the documentation for String#=~?

ratdog:~ mike$ irb
irb(main):001:0> “[” =~ /[/
=> 0
irb(main):002:0> “x” =~ /[/
=> nil
irb(main):003:0> “this[that]” =~ /[/
=> 4

Mike

Mike S. [email protected]
http://www.stok.ca/~mike/

The “`Stok’ disclaimers” apply.

Sorry and thx
I have expected 1, count of matching