cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

How to use a repetition pattern with Arbortext Command Language

dgopois
12-Amethyst

How to use a repetition pattern with Arbortext Command Language

Hello,

With ACL and search functions (gsub, sub or others), how to match a repetition pattern using the characters { } ?

Exemple of a repetition pattern: [0-9]{4}.

Regards

David

1 ACCEPTED SOLUTION

Accepted Solutions

ACL's regular expressions don't support explicit quantifiers (e.g. {4}). They only support *, ?, and +.

 

However, you can probably use Javascript and use it's much better regular expression handling to do what you need to do. Write a function in Javascript to do what you need, put it in a *.js file, make sure you load (source) it when Arbortext starts, and then you can call it using the ACL javascript() function.

View solution in original post

3 REPLIES 3

ACL's regular expressions don't support explicit quantifiers (e.g. {4}). They only support *, ?, and +.

 

However, you can probably use Javascript and use it's much better regular expression handling to do what you need to do. Write a function in Javascript to do what you need, put it in a *.js file, make sure you load (source) it when Arbortext starts, and then you can call it using the ACL javascript() function.

Clay,

 

Thanks for your response.

I have used your solution using a Javascript function.

Regards

 

David

I like Clay's idea of piping out to another language to do the heavy lifting on regex, if you're doing a lot of clever things then you may be reaching the limits of ACL. The only other idea would be to "unroll" your repeats e.g. in your example [0-9]?[0-9]?[0-9]?[0-9]? would match between 0 and 4 numbers. That wouldn't work if you need a min/max repeat, but does work for 0-n. It is very ugly.

Top Tags