Focal Point
[SOLVED] Extract Multiple Hashtags from text

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/3087085486

November 15, 2016, 03:10 PM
ChadSS
[SOLVED] Extract Multiple Hashtags from text
I tried to figure this one out myself, but I was unsuccessful. Any suggestions would be appreciated.

I have a large text field (A500) and I need to extract each word that begins with a hashtag '#' into a separate column within an Excel document.

Example data text: A boy name #Jack ran up the #hill to fetch a pail of #water on #11/14/2016.

From the example I am hoping to extract #Jack, #hill, #water, and #11/14/2016 and then place them into an output where each hashtag is a separate field. In the example there will be four columns, but the text field can be random. Could be zero hashtags or could be up to 10.

This message has been edited. Last edited by: ChadSS,
November 15, 2016, 05:53 PM
Tony A
Look at using GETTOK.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
November 16, 2016, 02:38 AM
Danny-SRL
GETTOK is the way to go:
  
-* File CHAD01.fex
DEFINE FILE CAR
STRING/A500='A boy name #Jack ran up the #hill to fetch a pail of #water on #11/14/2016';
MYSTRING/A502='#x' || STRING;
-REPEAT #HASH FOR &I FROM 1 TO 10;
-SET &J=&I + 1;
PHASH&I/A200=GETTOK(MYSTRING, 501, &J, '#', 200, 'A200');
THASH&I/A20=GETTOK(PHASH&I, 200, 1, ' ', 20, 'A20');
HASH&I/A21=IF THASH&I EQ ' ' THEN ' ' ELSE '#' || THASH&I;
-#HASH
END

TABLE FILE CAR
PRINT COUNTRY NOPRINT
-REPEAT #TAGS FOR &I FROM 1 TO 10;
HASH&I
-#TAGS
IF RECORDLIMIT EQ 1
END



Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

November 16, 2016, 09:00 AM
Prarie
Sweet... Smiler
November 16, 2016, 11:25 AM
ChadSS
Thanks Danny-SRL, worked like a charm.