You are here:
BACCHUS Wiki
>
System Web
>
ReferenceManual
>
UserDocumentationCategory
>
RegularExpression
(revision 1) (raw view)
---+!! Regular Expressions %TOC% ---++ Introduction Regular expressions (REs), unlike simple queries, allow you to search for text which matches a particular pattern. REs are similar to (but much more powerful than) the "wildcards" used in the command-line interfaces found in operating systems such as Unix and MS-DOS. REs are supported by sophisticated search engines, as well as by many Unix-based languages and tools ( e.g., =awk=, =grep=, =lex=, =perl=, and =sed= ). ---++ Examples | =compan(y|ies)= | Search for *company* _or_ *companies* | | =(peter|paul)= | Search for *peter* _or_ *paul* | | =bug*= | Search for *bug*, *bugg*, *buggg* or simply *bu* (a star matches *zero* or more instances of the previous character) | | =bug.*= | Search for *bug*, *bugs*, *bugfix* (a dot-star matches zero or more instances of *any* character) | | =[Bb]ag= | Search for *Bag*, *bag* | | =b[aiueo]g= | Second letter is a vowel. Matches *bag*, *bug*, *big* | | =b.g= | Second letter is any letter. Matches also *b&g* | | =[a-zA-Z]= | Matches any one letter (but not a number or a symbol) | | =[^0-9a-zA-Z]= | Matches any symbol (but not a number or a letter) | | =[A-Z][A-Z]*= | Matches one or more uppercase letters | | =[0-9]{3}-[0-9]{2}-[0-9]{4}= | US social security number, e.g. *123-45-6789* | =%<nop>SEARCH{type="regex"}%= also supports the =;= and =!= operators in regular expression searches. * =;= is used to indicate an "and" search. For example, =Peace;War= to search for topics matching the regular expressions =Peace= _and_ =War=. * =!= is used to negate the sense of the following regular expression. For example, =Peace;!War= will find topics that match the expression =Peace=, but do _not_ match the expression =War=. The =";"= and ="!"= operators are =%SEARCH= -specific and are not part of the standard regular expression syntax. ---++ Use of Advanced Regular Expressions Foswiki strives to support as much as possible of the Perl syntax for regular expressions. Be warned, though, that Foswiki only guarantees to support a subset of regular expression syntax, as documented in Foswiki:Development.RegularExpressions. This limitation is imposed by the third-party tools that Foswiki integrates with. You can use more advanced features of Perl regular expressions, but your searches are not guaranteed to be supported on all Foswiki configurations, for example where a database store is in use and the database doesn't support the full Perl syntax for REs. *Related Links:* * http://perldoc.perl.org/perlretut.html - Regular expressions tutorial * http://www.perl.com/doc/manual/html/pod/perlre.html - Perl regular expressions --- *Related Topics:* UserDocumentationCategory
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r1
|
B
acklinks
|
V
iew topic
|
Edit
w
iki text
|
M
ore topic actions
Topic revision: r1 - 26 Jun 2010,
ProjectContributor
System
Log In
Toolbox
Users
Groups
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
User Reference
BeginnersStartHere
TextFormattingRules
Macros
FormattedSearch
QuerySearch
DocumentGraphics
SkinBrowser
InstalledPlugins
Admin Maintenance
Reference Manual
AdminToolsCategory
InterWikis
ManagingWebs
SiteTools
DefaultPreferences
WebPreferences
Categories
Admin Documentation
Admin Tools
Developer Doc
User Documentation
User Tools
Copyright &© by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding BACCHUS Wiki?
Send feedback