Just to point out the obvious, you've got a closing bracket missing after the "(?!a" in the two examples you posted. I'm assuming it is a typing error, but thought I'd better check:
Regexp_substr( 'B2B' , '(?<!a)\d(?!a' )
Regexp_replace( 'B2B' , '(?<!a)\d(?!a', '#' )
-Paul.
-----Original Message-----
From: WDSCI-L [mailto:wdsci-l-bounces@xxxxxxxxxxxx] On Behalf Of Craig Richards
Sent: 28 April 2016 10:42
To: Rational Developer for IBM i / Websphere Development Studio Client for System i & iSeries
Subject: [WDSCI-L] DB2 regex bug with look around ?
Apologies if this isn't quite the correct forum for this question, but it seems a good place to get a chance of a second opinion...
Has anyone noticed anything funny with the look around regex capabilities of DB2 ( 7.1 )
For example
Applying
(?<!a)\d(?!a)
To
B2B
It should return
2
But it seems to find a match but with no text returned.
E.g if you run:
Select
Regexp_substr( 'B2B' , '(?<!a)\d(?!a' )
From sysibm/sysdummy1
It doesn't return null and it appears as blank in STRSQL.
whereas if you run the regex over 'a2B' you clearly get null returned.
But it should select the digit as far as I understand.
Further,
Select
Regexp_replace( 'B2B' , '(?<!a)\d(?!a', '#' ) From sysibm/sysdummy1
Will return B#2B
which seems to indicate that the regex selected the position just after the B where the negative look behind matched, but then didn't appear to go on and match the digit.
Does this make sense to anyone?
The regex is saying "find me a digit which doesn't have an "a" on either side of it"
Am I missing something obvious?
Thanks,
Craig
--
This is the Rational Developer for IBM i / Websphere Development Studio Client for System i & iSeries (WDSCI-L) mailing list To post a message email: WDSCI-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/wdsci-l
or email: WDSCI-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/wdsci-l.
---------------------------------------------------------------------------------------
Important This email transmission and any files with it are strictly confidential to the intended recipient and may be legally privileged. Any views or opinions presented are solely those of the author and do not necessarily represent those of BHSF. If you are not the intended recipient, you must not copy, disclose or distribute its contents in any way.
If you have received this email in error, please notify the sender and delete the email from your system. We have taken steps to ensure this email and attachments are free from any virus but do not accept any responsibility once this e-mail has been transmitted. You should scan any attachments for viruses. No contract may be concluded on behalf of BHSF Group Limited or its subsidiary companies by email.
Registered Office: BHSF Group Limited, Gamgee House, 2 Darnley Road, Birmingham B16 8TE. Registered in England number 04767689. BHSF is authorised and regulated by the Financial Conduct Authority and Prudential Regulation Authority.
This email has been scanned for email related threats and delivered safely by Mimecast. For more information please visit
https://www.mimecast.com
---------------------------------------------------------------------------------------
As an Amazon Associate we earn from qualifying purchases.