regex - How to use alternation in character class -


without being specific particular programming language i've been looking @ regular expressions.

as understand alternative notation a|b using character class [ab].

so if have regex ab|cd reads a followed b or c followed d how can use character class this?

this assume wouldn't work: [abcd] right answer: [(ab)(cd)] - looks bit strange me reason.

character class alone match single character. here need use capturing or non-capturing group if want apply or group of characters.

(ab|cd) 

or

(?:ab|cd) 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -