How to convert a glob with braces to a regex -


i want change glob such c{at,lif} in regex. like? i've tried using /c[at,lif]/ did not work.

for basic grep operation see f.e. http://www.regular-expressions.info/refquick.html

from http://www.regular-expressions.info/alternation.html:

if want search literal text cat or dog, separate both options vertical bar or pipe symbol: cat|dog. if want more options, expand list: cat|dog|mouse|fish.

this suggests following should work:

/c(at|lif)/ 

obligatory wrong yours, then:

/c[at,lif]/ 

the square brackets [..] not used in grep grouping, define character class. is, here create custom class allows 1 of characters at,lif. matches ca or c, or cf -- 1 character. adding repetition code c[at,lif]+ appears work because match both cat , clif, cilt, calf, , c,a,t.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -