Skip to main content
First of all, my apologies for asking this question. I have found some very useful articles in this community, but I can't quite make this transformer work exactly for my case.

 

 

I have a column in a text file containing something like this:

 

 

SRID=3005;POINT(1053949.68 557173.501)   I would like to obtain values like these, within _matched_parts, like this:

 

 

_matched_parts{0} = 1053949.68

 

_matched_parts{1} = 557173.501

 

 

I WANT TO EXTRACT ONLY THE COORDINATES BETWEEN THE PARENTHESIS.

 

  I have tried regular expressions such like this:

 

 

^( 0-9]*p.] 0-9]*) (-0-9]*].]-0-9]*)$

 

 

and also this one:

 

 

(:0-9]{1,2}<\\. 0-9]*]) (]0-9]{1,3}[\\.]0-9]*])

 

 

They both failed and no results are obtained:

 

 

"Coordinates(TestFactory): Tested 87 input feature(s) -- 0 feature(s) passed and 87 feature(s) failed"

 

 

So I know the syntax is somehow correct, but I can't really make it work.

 

 

I am using the StringSearcher and planning to use the 2DPointReplacer with the following input (output from the StringSearcher), to create the geometry

 

 

_matched_parts{0}

 

_matched_parts{1}

 

 

So far, the transformer does not make it to this point, as the String Searcher is not quite outputting the two right numbers to be used in the 2DPointReplacer

 

 

Could any of you please tell me how should the regular expression be built, so it returns those numbers?

 

 

Thank you very much,

 

 

Richard
Hi Richard!

 

 

POINT(1053949.68 557173.501)

 

 is on the format of OGC Well Known Text so I would do the following o get the coordinate:

 

 

 


Hi there!!

 

 

Thanks so much for your answer! It is greatly well documented. Although the solution was quite simple, I was going in the complete different direction than i should have.

 

 

Once again, great answer. I spent a couple of days to try to solve an issue using the wrong method and trying to make it work.

 

 

Much appreciated.

 

 

best regards,

 

 

Richard,
Hi Richard,

 

 

creating a regexp that matches any floating point number is actually surprisingly hard. For reference, here is one that matches pretty much any number, including integers and negative values (but not exponential notation):

 

 

<-+]?(+0-9]*\\.*0-9]+|90-9]+)

 

 

If we extend that to your requirement, we get:

 

 

\\((<-+]?((0-9]*\\.00-9]+|.0-9]+))\\s?(+-+]?(?0-9]*\\.00-9]+|.0-9]+))\\)

 

 

which will return one group for each of the floating point values inside the paranthesis.

 

 

But SigTill is absolutely right, it is much easier to just use a GeometryReplacer with OGCWKT as type to extract the geometry and take it from there :-)

 

 

David
Once again, thanks so much to both. I look forward to learn more about this tool and collaborate in this forum

 

 

All the best to both, great postings.

 

 

Richard.
[-+]?([0-9]+\\.+[0-9]+)

 

 

is better considering the input attribute as it will ignore the srid

Reply