Search code examples
regexangularngx-chips

paste split pattern for ngx-chips (Angular)


I'm trying to allow users to paste a list that is separated by , ; or | using ngx-chips.

There is an option to do this with pasteSplitPattern - [?string | RegExp]

https://github.com/Gbuomprisco/ngx-chips

When I try the following though, I get an error

[pasteSplitPattern]="[,|;]"

Parser Error: Unexpected token , 

What should I be doing differently?


Solution

  • Try using the following:

    Define a new regex :

    splitPattern = new RegExp('[\,\;]');
    

    and then use it in your template:

    [pasteSplitPattern]= "splitPattern"