oracle11g - instr() in oracle 11g -


sql> select instr('stringrings','rin',-4,1) dual;  instr('stringrings','rin',-4,1) -------------------------------                               7 

when provide search position -4 , searches backward right left, returns match position 7 though whole pattern not match given search starting position. here partial pattern matches in original string.

sql> select instr('stringrings','rin',-5,1) dual;  instr('stringrings','rin',-5,1) -------------------------------                               7 

here same result...

sql> select instr('stringrings','rin',4,1) dual;  instr('stringrings','rin',4,1) ------------------------------                              7 

but here, in positive direction search ignores partial pattern match , gives position exact pattern matches.. can explain me? why double standards?

no double standarts:

select instr('stringrings','rin',-4,1) dual; 

instr start search stringrings (-4), searching backward until first rin = stringrings (7)

select instr('stringrings','rin',-5,1) dual; 

instr start search stringrings (-5), searching backward until first rin = stringrings (7)

select instr('stringrings','rin',4,1) dual; 

instr start search stringrings (4), searching foreward until first rin = stringrings (7)


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -