Category: 

What is a Metacharacter?

Article Details
  • Written By: Sherry Holetzky
  • Edited By: Bronwyn Harris
  • Last Modified Date: 12 September 2016
  • Copyright Protected:
    2003-2016
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
The atmosphere of Jupiter's moon Io collapses every time it is eclipsed by the planet.   more...

September 29 ,  2008 :  The Dow Jones Industrial Average experienced its largest one-day drop in history.  more...

A metacharacter is one of a number of characters that, when used, does not represent any of the various letters or numbers that we commonly use to communicate. A metacharacter has a specific meaning such as indicating that various words should be separated in a line of code.

The metacharacter tells your computer how to proceed, in essence, explaining what to do with the characters that follow the metacharacter. In other words, a computer’s operating system will read a metacharacter, interpret what it means, and then perform an action based on that interpretation. Such an action may include instructing the system to separate statements or searching for different spellings of a word.

A metacharacter can be created from a variety of symbols, including punctuation marks. When a metacharacter is not needed, and punctuation marks are used for their original purpose, they must be set apart from the rest of the string. This can be done by either placing them within quotation marks or using a backslash. Another term for setting such a symbol apart is “escaping.”

Another example of a metacharacter is using one of the other standard symbols in a different way, such as using the the dollar sign to indicate the end of a line. A question mark is a very useful metacharacter when performing searches. You may not know precisely how a given word is spelled in a file, a common example being “honor” or “honour.”

Ad

In order to instruct your system to look for both spellings, you would type "hono(u)?r." The metcharacter, in this case the question mark, then tells your computer to find the word honor regardless of how it is spelled, with or without the “u.” On the other hand, if you’re searching for a metacharacter, you need to quote it or precede it with a backlash in order to search for it in its common usage. Say you wanted to search for just the question mark. Since it is a metacharacter, you would have to use the backslash in front of it or quotation marks around it in order to get the system to follow your command.

While some metcharacters have specific purposes or only match certain characters, there are also those that match any character. The dot, or the period, is one of them. A metacharacter that matches any character is known as a "wildcard."

Ad

You might also Like

Recommended

Discuss this Article

Post your comments

exception 'Exception' with message 'error writing captcha: Duplicate entry '2147483647' for key 'PRIMARY'' in /ssd/www/wisegeek/public_html/_core/classes/public/Captcha.php:44
Stack trace:
#0 /ssd/www/wisegeek/public_html/_core/controls/public/ControlDiscussionPostBox.php(324): Captcha->createCaptcha()
#1 /ssd/www/wisegeek/public_html/framework/classes/Control.php(104): ControlDiscussionPostBox->preRender(false)
#2 /ssd/www/wisegeek/public_html/framework/classes/Control.php(149): Control->render()
#3 /ssd/www/wisegeek/public_html/tpl/default-nocustom-lu/pages/public/article/article.htm(526): Control->__toString()
#4 /ssd/www/wisegeek/public_html/framework/classes/Control.php(300): require('/ssd/www/wisege...')
#5 /ssd/www/wisegeek/public_html/framework/classes/Control.php(309): Control->requireTpl('pages/public/ar...', Object(PageArticleCom), true)
#6 /ssd/www/wisegeek/public_html/framework/classes/Control.php(131): Control->renderTpl('pages/public/ar...', Object(PageArticleCom))
#7 /ssd/www/wisegeek/public_html/framework/classes/FormDataControl.php(87): Control->renderTemplate()
#8 /ssd/www/wisegeek/public_html/framework/classes/Control.php(109): FormDataControl->renderTemplate()
#9 /ssd/www/wisegeek/public_html/framework/classes/ScriptPage.php(50): Control->render(false)
#10 /ssd/www/wisegeek/public_html/framework/classes/Control.php(149): ScriptPage->render()
#11 /ssd/www/wisegeek/public_html/framework/classes/Page.php(97): Control->__toString()
#12 /ssd/www/wisegeek/public_html/_core/classes/public/PublicFrontController.php(443): Page->processRequest()
#13 /ssd/www/wisegeek/public_html/_core/classes/public/PublicFrontController.php(7): PublicFrontController->renderPage()
#14 /ssd/www/wisegeek/public_html/index.php(11): PublicFrontController::run()
#15 {main}