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

  • 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...
  • 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