View RSS Feed

Java String

What are Metacharacters

Rate this Entry
by , 04-26-2012 at 06:47 PM (559 Views)
Special characters are also supported by this API which places an affect at the mode by which a pattern is matched. Regular expressions can be changed to cat. & input string to tocats. Output will be as following:
Enter regex i.e. cat.

Enter “input string” for searching i.e. cats
Text cats are found that start at index zero & end at index four.
Match succeeds even dot is absent in input string. Match succeeds as dots are metacharacters, a character that has special kind of meaning that a match interprets. Metacharacter dot is any character and this is why match succeeded in given example.
API supports the metacharacters which are: <([{\^-=$!|]})?*+.>

Two methods for enforcing metacharacter to be taken as ordinary character are as following;
• Preceding of the metacharacter, with a backslash
• Enclosing it in \Q (that begins the quote), & \E (that ends the quote).
When this technique is used, the \E and \Q might be placed anywhere in expression. The only condition is that \Q shall come first.

Submit "What are Metacharacters" to Facebook Submit "What are Metacharacters" to Digg Submit "What are Metacharacters" to del.icio.us Submit "What are Metacharacters" to StumbleUpon Submit "What are Metacharacters" to Google

Categories
Regex

Comments