Tuesday, 15 June 2010

regex - "Match a literal character", or "match a character literally"? -



regex - "Match a literal character", or "match a character literally"? -

i making regex using regex101 tool , read in explanation field

[.] - literal character .

[\.] - matches character . literally

i lost between "literal character" , "character literally". difference between these two?

there no difference. sorry, take back. difference words firas dib, author of regx101, chose explain various tokens.

a literal character or matching literally refers specifying actual character in text: instance, a match a, opposed character class such \w match a.

you can match literal period in either of these 3 ways:

\. [.] [\.]

which alternative better?

some people alternative 2 because makes clear matching period, not catch-all dot. stands out. myself, utilize \.. people using character class less optimal, on modern processors makes no difference. pick. option 3 on top , typically used when doesn't know periods don't need escaped within character class. in view it's confusing. did author mean? trying create character class match either backslash or period, , made typo? (that [\\.]

regex

No comments:

Post a Comment