Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.



Read-Only Read-Only Topic
Go
Search
Notify
Tools
Number Extraction
 Login/Join
 
Platinum Member
posted
I would like to pull all numbers from a string, for example, numbers that are set in a varchar field, I'd like to just pull the numbers that were entered, versus anything else that may have landed in there.

so instead of '-93s90', I'd like '9390'

Any thoughts?

Thanks!

This message has been edited. Last edited by: gregson06,
 
Posts: 87 | Registered: August 03, 2006Report This Post
Platinum Member
posted Hide Post
gregson,

At http://documentation.informationbuilders.com/masterinde...acter22.htm#1127750, you will find this example( you'll need an IBI account to access it):

Syntax: How to Remove a Character From a String
STRIP(length, string, char, outfield)where:

length

Integer


Is the length in characters of string and outfield, or a field that contains the length.


string

Alphanumeric


Is an alphanumeric string, or the field from which the character will be removed.


char

Alphanumeric


Is the character to be removed from the string. This can be an alphanumeric literal enclosed in single quotation marks, or a field that contains the character. If it is a field, the left-most character in the field will be used as the strip character.


Note: To remove single quotation marks, use two consecutive quotation marks. You must then enclose this character combination in single quotation marks.


outfield

Alphanumeric


Is the field that contains the result, or the format of the output value enclosed in single quotation marks.


In Dialogue Manager, you must specify the format.



--------------------------------------------------------------------------------
Top of page
--------------------------------------------------------------------------------


Example: Removing Occurrences of a Character From a String (Reporting)
STRIP removes all occurrences of a period (.) from the DIRECTOR field and stores the result in a field with the format A17:

TABLE FILE MOVIESPRINT DIRECTOR AND COMPUTESDIR/A17 = STRIP(17, DIRECTOR, '.', 'A17');WHERE CATEGORY EQ `COMEDY'ENDThe output is:

DIRECTOR
SDIR

ZEMECKIS R.
ZEMECKIS R

ABRAHAMS J.
ABRAHAMS J

ALLEN W.
ALLEN W

HALLSTROM L.
HALLSTROM L

MARSHALL P.
MARSHALL P

BROOKS J.L.
BROOKS JL


You can also find this function in the "Using Functions" manual. An extremely useful, manual, by the way


dwf
 
Posts: 135 | Location: Portland, OR | Registered: March 23, 2005Report This Post
Platinum Member
posted Hide Post
Assuming you don't know which character will need to be replaced, you can try something like the following example:

-SET &STRING = '+-/93s90X4+*';

-SET &STR_LNG = &STRING.LENGTH;

-TYPE STR_LNG: (&STR_LNG)

-SET &IDX = 1;
-SET &PARSED_STR = '';

-REPEAT :PARSELOOP WHILE &IDX LE &STR_LNG;

-* Get the next character in the string
-SET &CHARACTER = SUBSTR(&STR_LNG , &STRING, &IDX, 
-                 &IDX, 1, 'A1');

-* Convert character to HEX, because straight character
-* comparison was accepting plus and minus characters
-SET &LNGU = 2;
-SET &FMTU = 'A' | &LNGU;
-SET &FIELDU = UFMT(&CHARACTER, 2, '&FMTU');

-* -TYPE (&CHARACTER : &FIELDU)


-SET &PARSED_STR = IF &FIELDU FROM '30' TO '39' THEN 
-                  &PARSED_STR || &CHARACTER ELSE
-                  TRUNCATE(&PARSED_STR) ;


-SET &IDX = &IDX + 1;

-:PARSELOOP

-TYPE Starting String: (&STRING)
-TYPE Parsed String :  (&PARSED_STR)


------------------------------------------------------------------------
PROD: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
TEST: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
 
Posts: 210 | Location: Ottawa | Registered: November 03, 2005Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic


Copyright © 1996-2020 Information Builders