Hi,
Â
Â
In this case, "string str" means a character string to be tested, and "string regExp" means a regular expression. For example, if an attribute called "wkt" stores the WKT (i.e. a character string to be tested), this expression returns the position (0-based index) of the part matched with "POLYGON" (i.e. regular expression). If not matched, returns -1.
Â
-----
Â
@FindRegEx(@Value(wkt),POLYGON)
Â
-----
Â
Â
However, if you need to determine if the string contains which one of "POINT", "POLYGON", "MULTIPOLYGON" etc., I think that "Conditional Value" setting is simpler than the @FindRegEx function. For example:
Â
Â
Â
Just be aware that you should test MULTIPOLYGON before POLYGON, since the test conditions will be evaluated in the order from top to bottom.
Â
Â
Takashi
OK...thanks for the reply. so @Value(wkt) indicates that the AttributeField is Value because it is preceded by the @Value()? Where is this documented?
See here.
Â
http://docs.safe.com/fme/html/FME_Workbench/Default.htm#transformer_parameters/Feature_Functions.htmÂ
Â
If you double-click or drag-and-drop the attribute name shown in FME Feature Attributes section, @Value(<attribute name>) will be added to the editor pane.Â
Â
Â
For the following string
Â
 POINT (9.9699121998145532 52.9278245931941953)
Â
Â
RegEx works when I enterÂ
Â
 ^POINT.*
Â
Â
But not when I use...
Â
 ^POINT \(
 and NOT when I write
Â
 ^POINT\s\(
 BUT...it works when I write
Â
 POINT\s\(.*
 Can you explain this?
Â
Â
Â
.* is 0 or more of any characterÂ
Â
Â
^POINT\\s\\(Â Â Â Â Â Â Â Â Â Â Â Â looks for a string ending with a (Â
Â
wich it does not
Â
POINT\\s\\(.*Â Â Â Â Â Â Â Â Â Â Â looks for a string ending with any character
Â
If u going to use more regexp
Â
http://www.tcl.tk/man/tcl8.4/TclCmd/re_syntax.htmÂ
Â
Â
there are many sites on this topic and for all flavors.
Didn't you get this error message?
Â
AttributeCreator: Unable to find closing bracket for function FindRegEx in
Â
Â
If the string literal to be passed to FME Function contains a paren, it should be quoted, like this. # This seems not to be documented.
Â
-----
Â
@FindRegEx(@Value(wkt),"^POINT \\(")
Â
-----
Â
I think the last expression will be also fail if it isn't quoted.
@FindRegEx(@Value(tsstr),^POINT \\()
Â
Â
does indeed yield error  AttributeCreator_2: Unable to find closing bracket for function FindRegEx
Â
Â
But it does not stop the proces, you just get "@FindRegEx(@Value(tsstr),^POINT \\()" as outputstring.
Â
Same goes for the last one indeed: POINT\\s\\(.*
Â
Â
Â
@FindRegEx(@Value(tsstr),^POINT \\((O\\d\\.\\s]*\\))) works with no quotes. Parens are balanced.
Â
Â
Also, often u need to use braces {}, when it contains reserved characters. But only when u dont wan't it to parse anything in the string.
Admittedly I´m no RegEx Expert, but I tested the regex here (
http://regex101.com/)
Â
Â
if I use this as a test string
Â
 POINT (9.9699121998145532 52.9278245931941953)
 and use the expression...
Â
Â
 ^POINT\s\(
Â
Â
without .*, then I get a match! I only want to match POINT\s\(....why do I need .*?
Â
Â
there are different flavors of regexp.
Â
Â
It does not mean it wil work in the transformer. To see if it works in the transformer you must run it. (i use RUbulator a lot, but Rubulator can use like 3 flavors or so).
Â
Â
If u want more options or possibility u can use a attribute creator and use tcl
Â
So in stead of using FindRegEx
Â
Â
u can use aregexp {exp} @Valeu(str)] this has a lot of ooptions. Look at
Â
 the link i send u. Almost all on that site work here.
Â
U can also use other tcl functions this way.
Â
Â
Â
without .*, then I get a match! I only want to match POINT\\s\\(....why do I need .*?
Â
Â
Because your string has mote items beyond the "(" so it wil not match.
Â
Â
and of course
Â
Â
regular expressions 101
Â
— an online regex tester for javascript, php, pcre and python
Â
wich is not the same as what is used in FME or tcl etc.
Â