s_novell Absent Member.
Absent Member.
254 views

Regular Expression


Hello All,
I'm working on regex which seems not working as expexted. The condition
i have is

-> if source attribute CN not match "^[0-9][0-9][0-9]"

i have CN value defined as "111_test"

but I'm seeing condition is evaluated as "True" for above CN value. Is
something wrong with regex?

I just need to veto if CN value does not start with any three numbers.

Thanks


--
s_novell
------------------------------------------------------------------------
s_novell's Profile: https://forums.netiq.com/member.php?userid=2529
View this thread: https://forums.netiq.com/showthread.php?t=53448

Labels (1)
0 Likes
2 Replies
Knowledge Partner Knowledge Partner
Knowledge Partner

Re: Regular Expression

Seeing the trace leading up to this would probably help a lot, since it
would show the values retrieved from the source and the comparison as it
takes place.

You may want to change your regex to have enough of a pattern to match the
entire value, such as the following:


^[0-9][0-9][0-9].*$


--
Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below...
0 Likes
Knowledge Partner
Knowledge Partner

Re: Regular Expression

s novell wrote:

>
> Hello All,
> I'm working on regex which seems not working as expexted. The condition
> i have is
>
> -> if source attribute CN not match "^[0-9][0-9][0-9]"
>
> i have CN value defined as "111_test"
>
> but I'm seeing condition is evaluated as "True" for above CN value. Is
> something wrong with regex?


You need to ensure that the remainder of the string gets matched by your expression. To modify your expression, you could write it like this:
^[0-9][0-9][0-9].*$

However, I would probably write it like this (to keep it concise):
^\d{3}.*$


> I just need to veto if CN value does not start with any three numbers.


Note both these expressions will permit more than 3 leading digits like:

1111_test

Alex McHugh - Knowledge Partner - Stavanger, Norway
Who are the Knowledge Partners
If you appreciate my comments, please click the Like button.
If I have resolved your issue, please click the Accept as Solution button.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.