Skip to main content
Solved

RegEx help needed (clean all except latlongs)


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

View original
Did this help you find an answer to your question?

7 replies

redgeographics
Celebrity
Forum|alt.badge.img+49

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
Supporter
  • 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
Supporter
  • August 25, 2017
takashi wrote:

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
Contributor
Forum|alt.badge.img+12
  • Contributor
  • 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
  • Participant
  • 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

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
  • September 4, 2017
andre_k wrote:

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

 

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings