First off, thank you for not shoving AI into Adaxes and for continuing to improve it.

I'm trying to set property pattern validation for new user creation and I'm a little stuck. Specifically, I want to make sure that the data entered:

  1. doesn't start with a space
  2. doesn't end with a space
  3. doesn't contain a 'smart' quote (‘ ’ “ ”)
  4. doesn't contain multiple sequential spaces (so no double/triple/etc spaces)

I did see I could impose the "must not start/end with" but that doesn't solve #3 and #4

Regex looks good but maybe I'm not quoting it properly? This does work for #1 and #2 but doesn't work for #3 unless there's two 'smart' quotes next to each other ^[^\s][^\‘\’\“\”]+[^\s]$ image.png image.png

I had tried this which didn't work for #3 either because it seems to see it as this string "‘’“”", regex101.com reckons it needs to be escaped like above. ^[^\s][^‘’“”]+[^\s]$

I haven't been able to figure out #4 multiple spaces cause adding \s{2,} doesn't work.

I could use Powershell validation but I'd prefer to have it on the form itself as then when the user is entering the data it tells them why it's an issue.

Am I just testing against the wrong flavor of regex? It does look like \‘\’\“\” would be incorrect for .NET because it doesn't need the backslashes but I tested with that and had the same issue of needing at least two 'smart' quotes to trigger the error message.

Any assistance is much appreciated

SOLVED: without numbers ^[A-Z](?:[a-zA-Z\'\-])*(?: [a-zA-Z\'\-]+)*$

with numbers ^[A-Z](?:[a-zA-Z0-9\'\-])*(?: [a-zA-Z0-9\'\-]+)*$

See bottom for more details or run it through regex101.com

by (20 points)

1 Answer

by (309k points)
0 votes

Hello,

Do we understand correctly that you need to actually allow only English letters and numbers? If that is correct, you can use the following regexp:

^[a-zA-Z0-9]$
by (20 points)
0

Hi,

Just to confirm - which flavor of regex is used for the property patterns? I need to know to know what needs escaping and what doesn't.

We need to allow any characters that could be part of a name, so including ' - (and maybe a couple others).

Doing just ^[a-zA-Z0-9 ]$ wouldn't prevent starting or ending with a space, nor would it prevent multiple sequential spaces - but using an allow-list isn't a bad idea. I tried with ^[^\s][a-zA-Z-\' ]+[^\s]$ and ^[^\s][a-zA-Z-' ]+[^\s]$ but both still allowed 'smart' quotes. image.png

Cheers, John

by (309k points)
0

Hello John,

Doing just ^[a-zA-Z0-9 ]$ wouldn't prevent starting or ending with a space, nor would it prevent multiple sequential space

First of all, there is no space in our regexp. Also, it does not allow any spaces at all. It only allows English letters (both upper case and lower case) and digits.

We need to allow any characters that could be part of a name, so including ' - (and maybe a couple others).

You can use the below regular expression:

^[a-zA-Z\-\`]+$
by (20 points)
0

Hi,

I think you need to (re-)read my messages as everything has been described pretty specifically IMHO.

I am aware that your proposed regex doesn't prevent leading or trailing whitespace (and doesn't differentiate between 'smart' quotes and an apostrophe), you'll also see that I had a workaround in my latest message.

Requirements

  1. doesn't start with a space
  2. doesn't end with a space
  3. doesn't contain a 'smart' quote (‘ ’ “ ”)
  4. doesn't contain multiple sequential spaces (so no double/triple/etc spaces)
  5. allows standard characters for a name ^[a-zA-Z0-9\'\-\ ]+$

Questions

What flavor regex does Adaxes use? Please don't make me ask a fourth time.

Current regex

^(?:[\w-[_0-9]])+(?: [a-zA-Z0-9\'\-]+)*$

Issues

Can't use 0-9'-, I'm guessing because of the regex flavor, the rest is working fine.

Here's my testing, you can also use the unit tests (left menu near the bottom) and you'll see this regex should be working fine https://regex101.com/r/NEh2Ja/4, I've assumed that Adaxes uses .NET regex.

by (309k points)
0

Hello,

Adaxes is using the .NET flavor for regex. As per our check, your regular expression works precisely as it is mentioned in the tests (at regex101.com) you provided. What exactly do you mean by Can't use 0-9'-?

by (20 points)
0

Having confirmed that it's .NET regex I've been able to figure out the required regex:

without numbers ^[A-Z](?:[a-zA-Z\'\-])*(?: [a-zA-Z\'\-]+)*$

with numbers ^[A-Z](?:[a-zA-Z0-9\'\-])*(?: [a-zA-Z0-9\'\-]+)*$

Allow:

  • single-character
  • a-z
  • A-Z
  • 0-9 (depending on regex)
  • '
  • -
  • single space
  • multiple non-sequential spaces

Require:

  • start with A-Z

Prevent:

  • leading space
  • trailing space
  • multiple sequential spaces

Related questions

I am trying to use a property pattern to prevent email forwarding to accounts in other domains managed by Adaxes. Here is my regex: ^([^,]+,)+(DC=domain,DC=local) ... 't working? Is Adaxes using some other value before resolving the DN? Thanks in advance! Leah

asked May 9, 2019 by loliver (120 points)
0 votes
1 answer

In this case the working example would be that the user would need to add a new title into a list of titles in the title property pattern

asked Dec 13, 2024 by msheppard (880 points)
0 votes
1 answer

The use case we are looking for is providing a list of titles for users to choose from when initiating a re-hire. We already have a title property pattern established and would ... that we can manage the list in one place. Let me know and as always, thanks.

asked Nov 22, 2024 by msheppard (880 points)
0 votes
1 answer

Is there a way I can bypass a property pattern for a set of users? For example we have an AP team that creates an account and want to restrict Job Title and Department to a ... we would like to be able to override that list. Is there an easy way to do that?

asked Sep 5, 2024 by curtisa (350 points)
0 votes
1 answer

I have a specific computer property pattern for three different types of computers, which live in three different OUs and are in three different business units. I will have ... How do I enforce a property pattern for a specific business unit at creation time?

asked Jul 17, 2023 by bennett.blodinger (60 points)
0 votes
1 answer