1

I need to match this bootstrap classes:

    '.col-lg-1',
    '.col-lg-2',
    '.col-lg-3',
    '.col-lg-4',
    '.col-lg-5',
    '.col-lg-6',
    '.col-lg-7',
    '.col-lg-8',
    '.col-lg-9',
    '.col-lg-10',
    '.col-lg-11',
    '.col-lg-12',
    '.col-md-1',
    '.col-md-2',
    '.col-md-3'

this in the gulpfile works.

When I try to do the same with regex:

'/.col-([a-zA-Z0-9]+)-([a-zA-Z0-9]+)/'

the classes are not ignored. I have checked the expression here: http://regexr.com/3f7ka

Whan am I doing wrong? Thank you.

aitor
  • 2,281
  • 3
  • 22
  • 44

1 Answers1

2

Removing surrounding apostrophe and doing global with g, it works:

/\.col-([a-zA-Z0-9]+)-([a-zA-Z0-9]+)/g,

https://stackoverflow.com/a/36358570/2986401

aitor
  • 2,281
  • 3
  • 22
  • 44
  • 1
    although this works for you atm, be sure to escape the "." at the beginning of the regexp. The dot is reserved for one instance of any single character. Coincidentally, in this case, that single character just happens to be ".". Best practice: escape the dot, like this: ```/\.col-([a-zA-Z0-9]+)-([a-zA-Z0-9]+)/g``` – lauri108 Mar 16 '21 at 07:35