You are here: Foswiki>Tasks Web>Item2028 (15 Mar 2011, GeorgeClark)Edit Attach

Item2028: Character classes in regex SEARCH broken

pencil
Priority: Enhancement
Current State: Confirmed
Released In: n/a
Target Release: n/a
Applies To: Engine
Component: SEARCH
Branches:
Reported By: MartinKaufmann
Waiting For:
Last Change By: GeorgeClark
The regex syntax for %SEARCH% is not implemented properly. I found at least two character classes which don't work as expected: \w and \s.

The example below illustrates the problem. The twi lines of text define the search target. The first search uses [a-z]+ and works as expected. The second search uses [\w]+ which should find the same but fails. In the third example, the white-space in the regex is written as a literal (" ") which works. If the white-space in the regex is replaced by \s, the search fails (4th search).

Under TWiki 4.1.2 all of these examples work as expected.

Search Target

footextbar

spam and some more text

Searched: ^foo[a-z]+bar

Results from Tasks web retrieved at 04:50 (GMT)

Number of topics: 1

Searched: ^foo[\w]+bar

Results from Tasks web retrieved at 04:50 (GMT)

Number of topics: 1

Searched: ^spam[a-z ]+text

Results from Tasks web retrieved at 04:50 (GMT)

Item2028
spam and some more text
Number of topics: 1

Searched: ^spam[a-z\s]+text

Results from Tasks web retrieved at 04:50 (GMT)

Item2028
spam and some more text
Number of topics: 1

-- MartinKaufmann

confirmed (painfully) that \s and such don't work. not confirmed in the sense that i don't know it was ever spec'ed to wok... :/ confirming, but changing to an enhancement until/unless there's documentation to point at saying this is supposed to work or was ever implemented.

-- WillNorris - 15 Feb 2010

I haven't come across any documentation either. I can only show some screenshots taken on my old TWiki® 4.1.2 installation.
  • Character class \s:
    regex-screenshot-1.png
  • Character class \w:
    regex-screenshot-2.png

-- MartinKaufmann - 15 Feb 2010

ItemTemplate edit

Summary Character classes in regex SEARCH broken
ReportedBy MartinKaufmann
Codebase 1.0.6
SVN Range Foswiki-1.0.0, Thu, 08 Jan 2009, build 1878
AppliesTo Engine
Component SEARCH
Priority Enhancement
CurrentState Confirmed
WaitingFor
Checkins
TargetRelease n/a
ReleasedIn n/a
I Attachment Action Size Date Who Comment
regex-screenshot-1.pngpng regex-screenshot-1.png manage 8 K 15 Feb 2010 - 10:28 MartinKaufmann TWiki 4.1.2 regex screenshot
regex-screenshot-2.pngpng regex-screenshot-2.png manage 8 K 15 Feb 2010 - 10:29 MartinKaufmann TWiki 4.1.2 regex screenshot
Topic revision: r5 - 15 Mar 2011, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy