View Full Version : Regulal Expression match problem

05-28-2003, 03:57 AM
This might sound silly, bu I try and match a string (stringCoparison condition bean) with a regular expression:
Just check that the line ends with a specific string (example "zzz").
I enter the expression zzz$ in the target property, and it always fails :( .
Other expressions like .*zzz succeed, so the bean works.
Am I wrong with the syntax??

help... :confused:

05-28-2003, 10:58 AM
There is a bug in the implementation of ISMP's GNU Regex that causes the '$' to match any character that terminates a string rather than the termination of the string (as expected). Thus, the expression "zzz$" will match "zzzx" but not "zzz".

06-04-2003, 02:43 AM

We had a similar problem. Try to add another character (like hash '#') to both the regular expression and the string you compare. This helped in our case.

See my thread concerning this problem:

Best regards

08-14-2003, 03:16 PM
I'm trying to do a regular expression comparison on a windows registry string. I need to see if the value in the string is a 0, 1, or 2. I tried using the expression


and do not get the correct result (i.e. it returns true when the value is 10). I assume this is caused by the same bug mentioned above. Is there a workaround for this type of comparison? I can't put a '#' after the source string because all the condition receives is the location of the string in the windows registry, not the string itself. Right now I'm getting around this just by using 3 conditions, (value is 0 OR 1 OR 2), but I have another bean that this will not work for and I need the regular expression to work. any ideas?

08-15-2003, 09:48 AM
The bug that I mention above with '$' in Gnu Regexp has been fixed in 5.0 SP2. Can you try with SP2?

08-19-2003, 09:36 AM
I tried using the same regular expression with service pack 2 and obtained the same results. ^[0-2]$ should match a 1-character string equal to "0", "1", or "2", but it is evaluating to true for the string "10" and false for the string "1". I'll just work around it for now.

04-08-2004, 04:21 PM
I'm using MP50 sp3 and I'm still having the same problem as originally posted by eldada.

04-08-2004, 05:18 PM
This is a known problem with the String Comparison bean in ISMP 5.0x (all service packs). For now, you will have to work around the problem as Markus described in this thread.

The problem will be fixed in the next release, due out in a few months.

04-08-2004, 06:04 PM
Markus's work around did work except you only add the extra # char to the source text:

compareText: .*$W(bean1.text)$
source: $W(bean2.text)#

To make it less confusing (to me) I chose to use $ instead of Marcus's suggested # as the extra char:

compareText: .*$W(bean1.text)$
source: $W(bean2.text)$