GetStyledWords ( )

Function stats

Average user rating
5.0000
38
140
9999
Support
FileMaker 8.0 +
Date posted
14 December 2008
Version
1
Recursive function
Yes

Author Info
 Daniele Raybaudi

9 functions

Average Rating 5.0

author_avatar



 

Function overview

Prototype

GetStyledWords  ( text ;   style )


Parameters

text   the given text where there are some styled words


style  the style to search for ; if it is empty the function will search for "plain"


Description

Tags:  Text Parsing  

Returns all the styled words ( in list view ) within the given text

Example 1):
text = I'm going ( bold ) to learn English ( bold )
GetStyledWords ( text ; "bold" ) returns:
going
English

Example 2):
text = I'm going ( bold ) to learn English ( bold )
GetStyledWords ( text ; "" ) or GetStyledWords ( text ; "plain" ) returns:
I'm
to
learn

Examples

Sample input

I'm going ( bold ) to learn English ( bold )


Sample output

going
English

 

Function code

/*
GetStyledWords custom function

( revision 1: now finds plain text, too. )


Author: Daniele Raybaudi

Format: GetStyledWords ( text ; style )

Parameters:
text - the given text where there are some styled words
style - the style to search for ; if it is empty the function will search for "plain"

Returns all the styled words ( in list view ) within the given text

Example 1):
text = I'm going ( bold ) to learn English ( bold )
GetStyledWords ( text ; "bold" ) returns:
going
English

Example 2):
text = I'm going ( bold ) to learn English ( bold )
GetStyledWords ( text ; "" ) or GetStyledWords ( text ; "plain" ) returns:
I'm
to
learn

*/
Let ( [
style = If ( IsEmpty ( style ) or style = "plain" ; "\"\"" ; style ) ;
svg = GetAsSVG ( text ) ;
parseSVG = MiddleValues ( svg ; 2 ; PatternCount ( svg ; "Style#" ) ) ;
nextSVG = RightValues ( svg ; ValueCount ( svg ) - 2 ) ;
line = GetValue ( parseSVG ; 1 );
pos1 = GetAsNumber ( Middle ( line ; Position ( line ; "," ; 1 ; 1 ) + 1 ; Position ( line ; "," ; 1 ; 2 ) - Position ( line ; "," ; 1 ; 1 ) - 1 ) ) ;
pos2 = GetAsNumber ( Middle ( line ; Position ( line ; "," ; 1 ; 2 ) + 1 ; Position ( line ; "<" ; 1 ; 2 ) - Position ( line ; "," ; 1 ; 2 ) - 1 ) ) ;
string = Middle ( text ; pos1 ; pos2 - pos1 + 1 );
adjString = Substitute ( TrimAll ( Substitute ( Middle ( text ; pos1 ; pos2 - pos1 + 1 ) ; ¶ ; " " ) ; 1; 1 ) ; " " ; ¶ ) ;
next = Trim ( Middle ( text ; Length ( string ) + 1 ; Length ( text ) ) )
] ;
Case (
PatternCount ( nextSVG ; style );
Case(
PatternCount ( line ; style ) ; adjString & ¶ & GetStyledWords ( next ; style );
GetStyledWords ( next ; style )
);
Case(
PatternCount ( line ; style ); adjString ;
""
)
)
)

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/140

    Prototype: GetStyledWords( text ; style )
    Function Author: Daniele Raybaudi (http://www.fmfunctions.com/mid/38)
    Last updated: 14 December 2008
    Version: 1

*/
// ===================================

 

 

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (31)
Date  (28)
XML  (26)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (12)
Layout Objects  (11)
Filter  (11)
Design  (10)
Array  (7)