Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001027Documentation, Examples, and Web SiteWriting with Informpublic2012-10-13 05:192014-05-07 07:38
Assigned Tograham 
Platformx86OSMac OS XOS Version10.8
Product Version6G60 
Target VersionFixed in Version6L02 
Summary0001027: Section 19.6 is confusing about the role of square brackets in regular expressions
DescriptionSection 19.6 says:

"In traditional regular expression language, square brackets rather than angle brackets are used for character ranges. In fact Inform does understand this notation (it treats square and angle brackets equally for this purpose), but square brackets would be annoying to type, since they already have a meaning in quoted text - for text substitutions."

This suggests that square brackets and angle brackets are treated the same in regexps. But in fact square brackets retain their role of indicating a text substitution, as well as character ranges.
Minimal Source Text To Reproduce
Lab is a room. 

After reading a command:
	if "axolotl barn swallow" matches the regular expression "\b[the player's command]\b":
say "Match!";
		 say "No match.";
	reject the player's command.
Test me with "x/axolotl". [Note: "test me" won't actually do anything.]
Additional InformationPerhaps nothing is actually false here, but it's confusing as all get-out. An example might be helpful.

Forum thread [^]
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
curiousdannii (developer)
2012-10-13 05:36

A possible clarification:

"In traditional regular expression language, square brackets rather than angle brackets are used for character ranges. In fact Inform does understand this notation, but only if you use "[bracket]" and "[close bracket]" because regular square brackets are used for text substitutions."
mattweiner (reporter)
2012-10-13 10:50

That's much clearer, but I think it could also use an explicit statement that it's OK to put text substitutions in the middle of regexps. Maybe with an example like this?

If we have

aeiou is a text that varies. aeiou is "lo".

The regular expression "b<aeiou>b" will match on "bab", "beb", "bib", "bob", and "bub".
The regular expression "b[aeiou]b" will match on "blob".
The regular expression "b[bracket]aeiou[close bracket]b" will match on "bab", "beb", "bib", "bob", and "bub".

Assuming that's right.
Felix Larsson (reporter)
2012-10-13 12:28

There's a similar potentially misleading wording in Example 403, “About Inform’s regular expression support”:
«(i) Inform allows angle brackets as synonymous with square brackets, for reasons explained above.»

- Issue History
Date Modified Username Field Change
2012-10-13 05:19 mattweiner New Issue
2012-10-13 05:36 curiousdannii Note Added: 0001898
2012-10-13 05:36 curiousdannii Status new => confirmed
2012-10-13 05:36 curiousdannii Steps to Reproduce Updated View Revisions
2012-10-13 10:50 mattweiner Note Added: 0001899
2012-10-13 12:28 Felix Larsson Note Added: 0001900
2014-01-25 09:00 graham Status confirmed => resolved
2014-01-25 09:00 graham Resolution open => fixed
2014-01-25 09:00 graham Assigned To => graham
2014-05-07 07:37 jmcgrew Fixed in Version => 6L02
2014-05-07 07:38 jmcgrew Status resolved => closed

Copyright © 2000 - 2010 MantisBT Group
Powered by Mantis Bugtracker