Domanda

I keep seeing undefined (?...) sequence: something. For this particular one I had..

/(?<!\d)[0-3]?\d(?!\d)/

but this has happened a few times to me and I'm not sure how to fix it.

These always work in rubular, but then i get that error when I run it?

Help please!

È stato utile?

Soluzione

its working here :

rituraj@rituraj:~$ irb
2.1.1 :001 > s = "somestring 23 and 34 and 233"
 => "somestring 23 and 34 and 233" 
2.1.1 :002 > s.scan(/(?<!\d)[0-3]?\d(?!\d)/)
 => ["23", "34"]

check your ruby version:

Ruby's regex engine doesn't support lookbehind which is less than 1.9.

You'd need to switch to 1.9+.

optional usage : you can use oniguruma

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top