branch and regular expressions

hello

The branch that i test is
switch on /string (evaluate labels = false)
/part [023]555-A/:sequence

i have a regular expression
/part [023]555-A/

those string match only for the strings
part 0555-A
part 2555-A
part 3555-A
this string will not match
part 02555-A

if i use only the expression
/[023]/
the precedent functions will match for all precedents strings

that’s not the result expected.

If i try with the service of PSUtilities
PSUtilities.regex:matches
all is as expected

do you have any advise ?

thanks in advance

Use /part [023]+555-A/
where the + indicates one or more instances of characters from the set, which I assume is what you’re after. If not please advise and we can get the right expression to use.

This worked with both a branch label and with PSUtilities.regex:matches (without the surrounding /).

My test with PSUtilities.regex:matches using
part [023]555-A
and value part 02555-A resulted in no match. I’m using IS 6.1 on JVM 1.4.2.

One of my favorite regex resources is one of the regex testing pages at either [URL=“RegexPlanet: online regular expression testing for Java”]http://www.fileformat.info/tool/regex.htm[/URL] or [URL=“JavaScript RegExp Example: Online Regular Expression Tester”]http://regexlib.com/RETester.aspx.[/URL]

The format of the regular expressions on this page may be slightly different than what you’d need in IS, but you can get the bulk of your regex pattern testing done here and then tweak for IS, if necessary.

Mark

reamon, what i want to is only to match the firsts tree strings not the forth one (with 0 AND 2)

mcarlson, the results retrun by the javascript version and the asp version are different.

are you agree with me that the regexp [023] or part [023]555
both must match with
part 0555
but not with
part 02555

the thing i want to test is a string that begin with a string that contains only 0 or 2 or 3. Not two of the precent characters. i have no matter of "part " and “555”. that was to take the exemple of webMethods Developer User’s Guide page 415. i want that “^0$” or “^2$” “^3$” match but not “^02$”

i don’t understand why regexp have different match on different languages implementations …
i don’t understand the difference of interpretation between part[023]555 and [023] expect of course part and 555.

i don’t think i’m very clear …

thank’s in advance for your help

ps : i’m using JVM 1.4.2 from sun and IS 6.1 too

Then I think the expression you started off with, part [023]555, is the one you want for the example given.

No. [023] will match when 0, 2, or 3 occurs anywhere within the string. It will, and should, match both your examples.

To make sure I understand, you’re looking for a regex way of implementing this:

BRANCH on someVar
0: SEQUENCE (do something)
2: SEQUENCE (do the same thing as 0)
3: SEQUENCE (do the same thing as 0 and 2)
$default: SEQUENCE (no match)

If I understand what you’re after, then /^0$|^2$|^3$/should do what you want.

Unless you anchor the regex with ^ or $ (beginning of string or end of string), then the pattern can occur anywhere within your string. Using your example, expression part [023]555 will match:

part 0555-A
part 2555-A
part 3555-A
junk part 3555-A fiddle faddle
garbage part 0555xxxyyyzzz

this string will not match
part 02555-A

But [023] will match all of them. Because this expression says “match if 0, 2 or 3 occur anywhere within the string.”

wadouk,

Seems to me that you want to ensure that the 1st character of the string is 0, 2, or 3 AND that the 2nd character of the string is NOT 0, 2, or 3. Is this correct?

If so, then assuming that your string is at least 2 characters long, you can use this regular expression: /[1][^023]/

Let me know if you need further clarification.

  • Percio

  1. 023 ↩︎

Hello,
if you need to match strings that only have one occurence of 0 or 2 or 3, then you have to use a regex like this:

/[1][023][^023]$/

this regex will match any strings like:
(anything_except_023)0or2or3(anything_except_023),

if You use /[023]/ only, it will match any string that have at least one 0 or 2 or 3,

but if you need to match strings that have any occurence of 0 or 2 or 3, but at lest one of them is not precede by 0 or 2 or 3, then you need to use:
/(^|[^023])023/

this will match strings like:
safa0safs0afsdf and sad02adfsd3test

but not
sassfd02sdafds

and the third option if You one to match
safa0safs0afsdf but not sad02adfsd3test

than an expression like
/^([^023](^|[^023])023[^023])*$/

should be use:)
this expression says that any occurence of 0,2,3 will not be precede by 0,2,3.

hope, that helps,
Kasper


  1. ^023 ↩︎

If I want to switch based on date pattern, what will be the syntax?
like yyyy-MM-dd, yyyyMMdd HH , etc.

This is difficult to achieve… if you recieve a date like
10/12/2006 it can be 10-Dec-2006 or 12-Oct-2006.

Do we have date pattern matching syntax like string pattern matching in WM?

yyyy-MM-dd, new pattern yyyyMMdd HH – dateFormat service should show as 20061013 00…You dont need mm ss??

HTH,
RMG

I want to use different dateTimeFormat service based on different current patterns using branch.

“different current patterns” do they provided you a list?? …Here is the goog search that came with
[URL=“Date and Time Formats”]http://www.w3.org/TR/NOTE-datetime[/URL]

I don’t think you can use webMethods branch service to achieve something based on a patter of the date…

You would have to know the pattern you are receiving in advance, from a standard, by agreement with a partner or from an indicator elsewhere in the data. There’s no way to determine it from the date alone. Retrieve the pattern from wherever it is stored, translate it to a consistent format of your choosing, map it to a string variable and branch on the value of that.

Tim

You must have the patterns that you are expecting to receive and then use branch operation and translate it to expected format.simple say there is no dyanamic way…

HTH
RMG