Question

Character on chain


Hi all,

 

 

I have a string like 400*856  The dimensions of a square.

 

I'm trying to separate both to get the with and hight.

 

 

I tried wit the "string searcher" but I'm not sure what i have to put to get the position of the "*"

 

Then use the substringextractor to make both atributtes.

 

 

Please Could anyone give me a clue?

 

 

Thanks you so much

 

Javier

 

 


4 replies

Userlevel 4
Hi,

 

 

here is one possibility: use a StringSearcher with the regular expression

 

 

(\\d+)\\D(\\d+)

 

 

it will separate the two numbers into _matched_parts{0} and _matched_parts{1}

 

 

David
David,

 

 

It didn't worked, but you gave me the hint.

 

 

I tried with

 

 

([0-9]*)[*]([0-9]*)

 

 

And worked. :)

 

 

I'm not used to these expresions.

 

 

Thanks you so much

 

 

Javier

 

 

Userlevel 2
Badge +17
Hi Javier,   The syntax of the regular expression "(\\d+)\\D(\\d+)" is correct, and the StringSearcher with this expression worked in my environment (FME 2013 SP2). You can learn more about regular expressions here. Another way: the AttributeSplitter (specify * as delimiter) could be a solution. For your Information.   Takashi
Hi Takashi   Thanks you so much for the link.   I can't use the atributteSpliter because the delimiter is not just "*"   Now I have values like   0.7 x 0.8 12 X 0.9   ( I hate them for not to use always the same format)     so I'm trying something like   ([0-9]*\\.[0-9]+|[0-9]+)[*x*|*X*]([0-9]*\\.[0-9]+|[0-9]+)   but when I accept an reopen the transformer the \\ disappears   ([0-9]*.[0-9]+|[0-9]+)[*x*|*X*]([0-9]*.[0-9]+|[0-9]+)

 

 

Any hint?

 

 

Thanks youSubmit

 

Reply