Regex look ahead & look behind alternative

1408
3
11-08-2017 06:29 AM
RenatoSalvaleon
Occasional Contributor III

I have a calculated value that will filter the letters t, s, or n separated by hyphens before or after.

My regex is looking for the single characters S, T, N, s, t or n that are between hyphens. JavaScript does not support the regex functions for look ahead and look behind. my regex is here: (?<=-)(t|s|n|T|S|N)(?=-)

Hope someone may have other regex or substring ideas how to parse this string value. Samples of  what I'm parsing is on the attached picture.

Thanks!

Tags (2)
0 Kudos
3 Replies
JamesTedrick
Esri Esteemed Contributor

Hi Renato,

It might be simpler to match for -[tsnTSN]- and simply get the character in position 1 (the middle of the 3 character string).

0 Kudos
RenatoSalvaleon
Occasional Contributor III

It seems Regex function can only be used for constraints and relevant. My regex in the Calculate column returned either 'true' or 'false' values. It makes sense why it will be supported in constraints and relevant columns. So I guess my only recourse is substring if my start and end values are consistent. Unfortunately, they are not. I guess will have to wait for future enhancement on this one.

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Renato,

The regex function can be used in calculations, but it provides a result of true or false - the same as the test() method (JavaScript test() Method); the XLSForm specification doesn't have a specification for extraction of a value.  Do you mind if I ask about this use case?

0 Kudos