Skip to main content
Solved

RegEx help needed (clean all except latlongs)

  • August 25, 2017
  • 7 replies
  • 23 views

Forum|alt.badge.img

Hi all,

I'm am looking for some Regex help to clean up my workflow.

 

I have used StringConcatenator to bring together latitude / longitude fields and to separate these with ", " (comma white space)

Unfortunately my data also contained empty fields and text resulting in:

, 51.50757358840452, 4.358557125886925aan, Alphen, Winterswijk

 

The only data I want to keep are the valid latlongs in bold.

 

Can you help me out with a regex string (to be used in StringReplacer) that cleans all except the valid latlongs?

Best,

Ed

Best answer by andre_k

Hi Ed,

this should work, at least for your example: 

^,.*|\D+,[ ]\D+

But maybe it's easier to get rid of the problem before you use the StringConcatenator ...

Best,

Andre

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

7 replies

redgeographics
Celebrity
Forum|alt.badge.img+60
  • Celebrity
  • 3704 replies
  • August 25, 2017

I try and avoid regexes as much as I can, so in this case I would look at the AttributeSplitter, assuming the number of fields is always the same (and they're always in the same order) it should handle empty fields just fine. It'll then generate a list from which you can pick the relevant itels as your lat/lons.


takashi
Celebrity
  • 7843 replies
  • August 25, 2017

Hi @edhere, alternatively, you can determine if the latitude and longitude values are valid as numeric representation with the AttributeValidator and then create the new attribute by concatenating them only if both were valid.

 


takashi
Celebrity
  • 7843 replies
  • August 25, 2017

Hi @edhere, alternatively, you can determine if the latitude and longitude values are valid as numeric representation with the AttributeValidator and then create the new attribute by concatenating them only if both were valid.

 

An advantage of the AttributeValidator is that you can also validate range of individual numeric values simultaneously like this, if necessary.

 


mygis
Supporter
Forum|alt.badge.img+14
  • Supporter
  • 307 replies
  • August 25, 2017

It looks as if you have a newline character could you try to search and replace NL with nothing? using the stringreplacer


andre_k
Participant
Forum|alt.badge.img+4
  • Participant
  • 1 reply
  • Best Answer
  • August 25, 2017

Hi Ed,

this should work, at least for your example: 

^,.*|\D+,[ ]\D+

But maybe it's easier to get rid of the problem before you use the StringConcatenator ...

Best,

Andre


Forum|alt.badge.img
  • 275 replies
  • August 25, 2017

Hi @edhere

I am a big fan of conditional values so I would use conditional values while getting the concatenated value (with e.g. AttributeCreator). The new concatenated LatLon value would be:

A closer look at the condition:


Forum|alt.badge.img
  • Author
  • 60 replies
  • September 4, 2017

Hi Ed,

this should work, at least for your example: 

^,.*|\D+,[ ]\D+

But maybe it's easier to get rid of the problem before you use the StringConcatenator ...

Best,

Andre

Hi Andre,

 

 

Thanks, this worked for now!

 

I'll look at the other comments here to try and clean up my data before using the StringConcatenator.

 

 

Best,

 

Ed