Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

ReGex Parse tool: Why isn't \D+ matching a less-than (<) symbol?

jlefeaux
8 - Asteroid

I'm new to RegEx and this is driving me crazy.

 

I'm trying to find non-numeric characters in a data field that should be numeric.

In this case one of my users entered '< 85' in their spreadsheet.

 

I've set up a RegEx Parse to look for \D+, which to my understanding should match any field that contains one or more non-digits.  My output method is Match, but this expression is not matching the '< 85'.

 

I tested it on https://regex101.com/ and it matches in their tester, so I'm not sure what's going on here.

 

Tiny example workflow attached.

 

Thank you!

11 REPLIES 11
neilgallen
12 - Quasar

random guess, but it could be the space. I'm not sure how non-digit accounts for spaces.

Thableaus
17 - Castor
17 - Castor

Hi @jlefeaux 

 

Match mode on RegEX checks the whole string for a match.

 

So basically, \D+ is checking if the whole string is a non-digit expression.

 

Cheers,

Thableaus
17 - Castor
17 - Castor

@jlefeaux 

 

Try ^\d*\D+\d* 

 

Can your numbers be decimals? If so, you have to consider the (.) as a character as well.

 

Cheers,

jlefeaux
8 - Asteroid

Hi @Thableaus.  Thanks for your suggestion, but sadly it did not work.

 

I've extended the sample workflow to include 2 bad examples and ^\d*\D+\d* did not catch either of them.

 

Capture.PNG

 

It's a good point about the decimal place & I will definitely address that once I get this issue figured out.

Thableaus
17 - Castor
17 - Castor

@jlefeaux 

 

You're adding an extra whitespace after the expression "^\d*\D+\d*"

 

Take off the extra whitespace at the end of the RegEX and it'll work.

 

Cheers,

Thableaus
17 - Castor
17 - Castor

@jlefeaux 

 

To match cases like <85+81 - let's say, non-digits with more digits

 

(^\d*\D+\d*)+ would do the trick.

 

Cheers, 

jlefeaux
8 - Asteroid

 

@Thableaus ,

 

Arrgh, the whitespace came from copying & pasting from the webpage.

 

Removing the whitespace worked on the sample set in my example... But your new expression did not match <85+81

 

I've updated the tiny workflow with '(^\d*\D+\d*)+' and '<85+81'  & included it here if you are interested in pursuing the question.  Regardless, I'm going to mark your previous post as the solution.

 

Thank you!

Thableaus
17 - Castor
17 - Castor

@jlefeaux 

 

Sorry, it's ^(\d*\D+\d*)+

 

^ refers to the beginning of the line. So it happens just once.

 

Cheers,

jlefeaux
8 - Asteroid

Ummm, acutally, no... it didn't :D

Labels