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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

How to use a repetition pattern with Arbortext Command Language

dgopois
13-Aquamarine

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

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.

dgopois
13-Aquamarine
(To:ClayHelberg)

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.

Announcements

Top Tags