Skip to main content
Question

String Function in Attribute Manager

  • January 14, 2020
  • 4 replies
  • 212 views

Forum|alt.badge.img

I have an attribute string such as 6-6.35@4T. Where the 6 before the "-" is size (which can be a two digits such as 12). The characters between the "-" and the "@" are a depth measurement (and could also be something like 20.50). The number after the "@" is a clock position and can be in the range between 1-12. The alpha character at the end is indicative of a type.

We captured the characters before the "-" as a size attribute. We did this using the string function - @Left(@Value(In_A),(@FindString(@Value(In_A),"-"))).

What is stumping us is how to capture all characters between the "-" and "@" as a depth attribute and the numbers after the "@" as a clock position?

We would like to accomplish this in the attribute manager if possible.

Any help is much appreciated.

4 replies

Forum|alt.badge.img+2
  • January 14, 2020

@jim In the StringSearcher you can use regex sub-expressions:

^([0-9]{1,2})-([0-9]+.[0-9]+)@.([A-Z])$

The () return sub-expressions that are then exposed by the StringSearcher as lists. The {1,2} mean one to two characters.

_sub_expressions{0}.part 6_sub_expressions{0}.startIndex 0_sub_expressions{1}.part 6.35_sub_expressions{1}.startIndex 2_sub_expressions{2}.part T_sub_expressions{2}.startIndex 8

I've attached a small example (2019.2): regex.fmw


david_r
Evangelist
  • January 14, 2020

The simplest solution is probably to use a StringSearcher with a regex and then use the AttributeRenamer to rename the individual match items. Example:

0684Q00000ArL8WQAV.png

Sample input:

6-105.35@10T

Output:

`size' has value `6'
`depth' has value `105.35'
`position' has value `10'
`type' has value `T'

arnold_bijlsma
Enthusiast
Forum|alt.badge.img+14
markatsafe wrote:

@jim In the StringSearcher you can use regex sub-expressions:

     ^([0-9]{1,2})-([0-9]+.[0-9]+)@.([A-Z])$

The () return sub-expressions that are then exposed by the StringSearcher as lists. The {1,2} mean one to two characters.

_sub_expressions{0}.part    6_sub_expressions{0}.startIndex    0_sub_expressions{1}.part    6.35_sub_expressions{1}.startIndex    2_sub_expressions{2}.part    T_sub_expressions{2}.startIndex    8

0684Q00000ArLJrQAN.png

I've attached a small example (2019.2): regex.fmw

Almost. The last . needs to be followed by a + to capture a string like 12-20.50@12A. And I would also put brackets around them to capture the clock position as a list element

^([0-9]{1,2})-([0-9]+.[0-9]+)@(.+)([A-Z])$

See https://regex101.com/r/enQYWi/2 (I replaced [0-9] by \d)


ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • January 14, 2020

If you were desperate to do it all in the AttributeManager then you could, it's not very readable though

For the depth you replace all the characters before and including the - with nothing, then you replace from that result, all of the characters after and including the @ with nothing

For the clock you replace everything up to and including the @with nothing, and trim the T off the end

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings