From: ben on 5 Apr 2010 05:18 Just wondering if a literal . needs to be escaped inside a bracket expression within a regexp. For example, I want this fragment to match any sequence of alphanumeric characters, underscores or '.'s [[:alnum:]_.] The man page for re_syntax suggests that only ] and - need to be escaped inside bracket expression, but it's not 100% clear on that point.
From: Alexandre Ferrieux on 5 Apr 2010 05:46 On Apr 5, 11:18 am, "b...(a)spam.com" <ben.carb...(a)gmail.com> wrote: > Just wondering if a literal . needs to be escaped inside a bracket > expression within a regexp. For example, I want this fragment to match > any sequence of alphanumeric characters, underscores or '.'s > > [[:alnum:]_.] > > The man page for re_syntax suggests that only ] and - need to be > escaped inside bracket expression, but it's not 100% clear on that > point. What may be misleading you is the use of the dot in [. .] (collating elements). But note that these are distinguishable from [.] or even [ANYTHING.] or [.ANYTHING]. So no, a single dot doesn't need escaping in a bracket expression. Personally I even tend to write [.] instead of \. because backslashes sting my eyes ;-) -Alex
From: ben on 5 Apr 2010 07:21 Thanks muchly.
From: Glenn Jackman on 5 Apr 2010 15:02 At 2010-04-05 05:46AM, "Alexandre Ferrieux" wrote: > On Apr 5, 11:18�am, "b...(a)spam.com" <ben.carb...(a)gmail.com> wrote: > > Just wondering if a literal . needs to be escaped inside a bracket > > expression within a regexp. For example, I want this fragment to match > > any sequence of alphanumeric characters, underscores or '.'s > > > > [[:alnum:]_.] > > > > The man page for re_syntax suggests that only ] and - need to be > > escaped inside bracket expression, but it's not 100% clear on that > > point. > > What may be misleading you is the use of the dot in [. .] (collating > elements). But note that these are distinguishable from [.] or even > [ANYTHING.] or [.ANYTHING]. So no, a single dot doesn't need escaping > in a bracket expression. Personally I even tend to write [.] instead > of \. because backslashes sting my eyes ;-) Additionally, you an write your character class as: [\w.] since a word char (\w) is letters, numbers and underscore -- Glenn Jackman Write a wise saying and your name will live forever. -- Anonymous
From: Donal K. Fellows on 5 Apr 2010 15:41 On 5 Apr, 20:02, Glenn Jackman <gle...(a)ncf.ca> wrote: > Additionally, you an write your character class as: [\w.] > since a word char (\w) is letters, numbers and underscore Only for some classes (the "positive" ones). Check the docs for re_syntax to see which is which. Donal.
|
Pages: 1 Prev: Where is the documentation for tk::PlaceWindow? Next: Junit like test report with tcltest?? |