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.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] extracting numbers from alphanumeric field

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] extracting numbers from alphanumeric field
 Login/Join
 
Platinum Member
posted
I am trying to extract only the numbers from an alphanumeric field that contains both numbers and letters. The field is a room number (ie. 1305B) and I need to separate out the numbers and letters. I am trying to do this via a define field and split the field into 2 new fields (one number and one letter), but I'm having trouble find a function or a combo of functions that will do the trick.

This message has been edited. Last edited by: Kerry,


-Brian

Webfocus v7.6.1 on Windows XP
 
Posts: 108 | Registered: June 19, 2006Report This Post
Virtuoso
posted Hide Post
Try this:

APP FILEDEF TESTMAS DISK testdata.mas
-RUN
-WRITE TESTMAS FILENAME=TESTDATA,SUFFIX=FIX
-WRITE TESTMAS SEGNAME=TESTDATA,SEGTYPE=S0
-WRITE TESTMAS FIELDNAME=TESTFLD ,ALIAS=TESTFLD ,FORMAT=A12 ,ACTUAL=A12 ,$
-*
APP FILEDEF TESTDATA DISK testdata.ftm
-RUN
-WRITE TESTDATA A 127366250
-WRITE TESTDATA 2B27364433
-WRITE TESTDATA 12C456789
-WRITE TESTDATA 800969INF0
-WRITE TESTDATA 1012D2898
-WRITE TESTDATA 10121E
-WRITE TESTDATA 2 Penn Plaza
-WRITE TESTDATA 917339F380
-WRITE TESTDATA 9173394G50
-WRITE TESTDATA 21273662H0
-WRITE TESTDATA 212736443I
-WRITE TESTDATA 2127366250
-WRITE TESTDATA 10121 J
-RUN
-*
DEFINE FILE TESTDATA
 PATTERNX/A12 = PATTERN (12,UPCASE(12,TESTFLD,'A12'),'A12');
 REPLACEA/A12 = STRREP (12,PATTERNX,1,'A',1,'$',12,'A12');
 REPLACEB/A12 = STRREP (12,REPLACEA,1,' ',1,'$',12,'A12');
 NUMBERS/A12  = EDIT(TESTFLD,REPLACEB);
 REPLACE1/A12 = STRREP (12,PATTERNX,1,'9',1,'$',12,'A12');
 REPLACE2/A12 = STRREP (12,REPLACE1,1,'A',1,'9',12,'A12');
 REPLACE3/A12 = STRREP (12,REPLACE2,1,' ',1,'9',12,'A12');
 LETTERS/A12  = EDIT(TESTFLD,REPLACE3);
END
-*
TABLE FILE TESTDATA
 PRINT TESTFLD NUMBERS LETTERS
END


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Expert
posted Hide Post
Awesome code, well done!



Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Virtuoso
posted Hide Post
Thanks Waz. I was both lucky and happy to discover that the EDIT function accepts a field as input for the 'mask' argument. This fact allows the combination of PATTERN and EDIT functions to provide a dandy solution to this type of problem.


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Master
posted Hide Post
Just wondering, anyone know what release PATTERN became available? We are on 7.1.3 and it is not part of our release.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
 
Posts: 975 | Location: Oklahoma City | Registered: October 27, 2006Report This Post
Virtuoso
posted Hide Post
Looks like it was 7.6.5. New Features - release 7.6.5


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Guru
posted Hide Post
It works in 7.6.4 as well, and is documented in the Using Functions Manual Version 7 Release 6


(Prod: WebFOCUS 7.7.03: Win 2008 & AIX hub/Servlet Mode; sub: AS/400 JDE; mostly Self Serve; DBs: Oracle, JDE, SQLServer; various output formats)
 
Posts: 391 | Location: California | Registered: April 14, 2003Report This Post
Virtuoso
posted Hide Post
If your version of FOCUS/WebFOCUS doesn't support function PATTERN, here is an alternative approach using the SUBSTR and CHKFMT functions. The -REPEAT loops are based on the length of the character string being tested (12 in this case), so make appropriate changes for the length of the string you are trying to split.

APP FILEDEF TESTMAS DISK testdata.mas
-RUN
-WRITE TESTMAS FILENAME=TESTDATA,SUFFIX=FIX
-WRITE TESTMAS SEGNAME=TESTDATA,SEGTYPE=S0
-WRITE TESTMAS FIELDNAME=TESTFLD ,ALIAS=TESTFLD ,FORMAT=A12 ,ACTUAL=A12 ,$
-*
APP FILEDEF TESTDATA DISK testdata.ftm
-RUN
-WRITE TESTDATA A 127366250
-WRITE TESTDATA 2B27364433
-WRITE TESTDATA 12C456789
-WRITE TESTDATA 800969INF0
-WRITE TESTDATA 1012D2898
-WRITE TESTDATA 10121E
-WRITE TESTDATA 2 Penn Plaza
-WRITE TESTDATA 917339F380
-WRITE TESTDATA 9173394G50
-WRITE TESTDATA 21273662H0
-WRITE TESTDATA 212736443I
-WRITE TESTDATA 2127366250
-WRITE TESTDATA 10121 J
-RUN
-*
DEFINE FILE TESTDATA
-REPEAT ENDREPEAT1 FOR &I FROM 1 TO 12
 TESTCHAR/A1  = SUBSTR(12,TESTFLD,&I,&I,1,'A1');
 CHECKFMT/I1  = CHKFMT(1,TESTCHAR,'9','I1');
 NUMBERS&I/A1 = IF (CHECKFMT EQ 0) THEN TESTCHAR ELSE '';
 LETTERS&I/A1 = IF (CHECKFMT NE 0) THEN TESTCHAR ELSE '';
-ENDREPEAT1
-*
 NUMBERS/A12 = NUMBERS1
-REPEAT ENDREPEAT2 FOR &I FROM 2 TO 12
 || NUMBERS&I
-ENDREPEAT2
 ;
-*
 LETTERS/A12 = LETTERS1
-REPEAT ENDREPEAT3 FOR &I FROM 2 TO 12
 || LETTERS&I
-ENDREPEAT3
 ;
END
-*
TABLE FILE TESTDATA
 PRINT TESTFLD NUMBERS LETTERS
END

This message has been edited. Last edited by: Dan Satchell,


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] extracting numbers from alphanumeric field

Copyright © 1996-2020 Information Builders