Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread PosExx() Function enchances Position() for searching strings
Wed, Jan 29 2014 3:16 PMPermanent Link

Barry

PosExx() Function:
==============
The PosExx() is an enhancement of the built-in EDB POSITION() function.
PosExx() returns the location of aSearchStr within aSourceStr but with several improvements.

PosExx() will search for aSearchStr in aSourceStr in either a forward or backward direction from an offset of aStart and the search can be case-insensitive.                              

Syntax:
=======
FUNCTION PosExx(aSearchStr VARCHAR(255),
                            aSourceStr VARCHAR(255),
                            aStart INTEGER,                  -- Optional.  Default = 1
                           aCaseInsensitive BOOLEAN)  -- Optional. Default=False
                 RETURNS INTEGER

                                                
Install Instructions:
=====================
1) Copy and paste the file "PosExx.Sql" into EDBMgr's Script window.
2) Modify the 'COLLATE UNI_CI' if necessary.
3) Execute the script to create the PosExx() function.
4) Test it with the samples statements below.
5) Enjoy!

select PosExx(''''ab'''',''''abdeabcABC'''')! --  returns 1  Same as POSITION()
select PosExx(''''ab'''',''''abdeabcABC'''', -1)! -- returns 5. Search backwards
select PosExx(''''ab'''',''''abdeabcABC'''', -1, true)! -- returns 8. Search backwards case insensitive
select PosExx(''''ab'''',''''abdeabcABC'''', 3, true)! -- returns 5.  Search from position 3, case insensitive
select PosExx(''''ab'''',''''abdeabcABC'''', -4, true)! -- returns 6. Search backwards from -4 (''''c'''') case insensitive''

Barry



Attachments: PosExx.zip
Wed, Jan 29 2014 7:27 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Barry,

Nice, thanks. Smile

Tim Young
Elevate Software
www.elevatesoft.com
Image