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

How to use a repetition pattern with Arbortext Command Language

SOLVED
Highlighted
Regular Member

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

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to use a repetition pattern with Arbortext Command Language

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.

3 REPLIES 3

Re: How to use a repetition pattern with Arbortext Command Language

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.

Re: How to use a repetition pattern with Arbortext Command Language

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.

Re: How to use a repetition pattern with Arbortext Command Language

Clay,

 

Thanks for your response.

I have used your solution using a Javascript function.

Regards

 

David