3

Is there a way to clean the values in the column to just have A-Z 0-9 and _ ?

In python/regex I run

def Alphanumeric(string):
 import re
 clean_string=re.sub(r'[^a-zA-Z0-9‌​_]', '', string)
 return clean_string

I need to do this in Mapinfo as an update column. I see something close in http://nyalldawson.net/2013/05/regular-expressions-in-mapbasic/ and am in the process of exploring this.

Additionally, I know I can run InStr() for each of these values but I am hoping for a one-liner.

1
  • 1
    In general you can build your own DLL with .NET (e.g. free MS Visual Studio Community Edition) having almost any function. Check chapter 12 - Integrated Mapping in MapBasic Documentation Oct 27, 2016 at 20:36

1 Answer 1

5

I searched for "mapbasic regex" and found what looks to be what you may need posted in the nyalldawson.net blog:

If you’re not familiar with regular expressions, they’re an extremely powerful tool for string manipulation. They can be somewhat daunting at first, but with a bit of practice they’ll open up all kinds of string processing which would otherwise be extremely convoluted or impossible.

Up until now there’s been no way of using the beauty of regular expressions within MapInfo. Now, with MbRegEx, all their mighty power can be fully utilised within your MapBasic scripts!

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.