String Palindrome Program In Cobol
CLICK HERE - https://bltlly.com/2tqk0Y
Approach: The string obviously has to be a palindrome, but that alone is not enough. All characters in the string should be symmetric so that their reflection is also the same. The symmetric characters are AHIMOTUVWXY.
Last modified: Fri Nov 27 09:44:51 2020Table of ContentsWhat is a Regular ExpressionThe Structure of a Regular ExpressionThe Anchor Characters: ^ and $Matching a character with a character setMatch any character with .Specifying a Range of Characters with [...]Exceptions in a character setRepeating character sets with *Matching a specific number of sets with \\{ and \\}Matching words with \\< and \\>Backreferences - Remembering patterns with \\(, \\) and \\1Potential ProblemsExtended Regular ExpressionsPOSIX character setsPerl ExtensionsThanksRegular Expressions and Extended Pattern MatchingBruce BarnettNote that this was written in 1991, before Linux. In the1980's, it was common to have different sets of regular expressionfeatures with different features. ed(1) was different from sed(1)which was different from vi(1), etc. Note thatSun went through every utility and forced each one to use one of twodistinct regular expression libraries - regular or extended. I wrote this tutorial for Sunusers, and some of the commands discussed are now obsolete. On Linux and other UNIX systems, you might find out that some of thesefeatures are not implemented. Your mileage may vary. Copyright 1991 Bruce Barnett & General Electric CompanyCopyright 2001, 2008, 2013 Bruce Barnett All Rights reserved Original version written in 1994 and published in the Sun ObserverWhat is a Regular ExpressionA regular expression is a set of characters that specify a pattern.The term \"regular\" has nothing to do with a high-fiber diet. It comes from a term used todescribe grammars and formal languages.Regular expressions are used when you want to search for specific linesof text containing a particular pattern.Most of the UNIX utilities operate on ASCII files a line at a time.Regular expressions search for patterns on a single line, and not forpatterns that start on one line and end on another.It is simple to search for a specific word or string of characters. Almost every editor on everycomputer system can do this.Regular expressions are more powerful and flexible.You can search for words of a certain size. You can search for a wordwith four or more vowels that end with an\"s\". Numbers, punctuation characters, you name it, a regular expression canfind it.What happens once the program you are using finds it is another matter.Some just search for the pattern. Others print out the line containingthe pattern. Editors can replace the string with a new pattern.It all depends on the utility.Regular expressions confuse people because they look a lot like thefile matching patterns the shell uses.They even act the same way--almost. The square brackets are similar, and the asterisk acts similar to, butnot identical to the asterisk in a regular expression.In particular, the Bourne shell, C shell, find, andcpio use file name matching patterns and not regular expressions.Remember that shellmeta-characters are expanded before the shell passes the arguments tothe program. To prevent this expansion, the special characters in a regularexpression must be quoted when passed as an option from the shell.You already know how to do this because I covered this topic in lastmonth's tutorial.The Structure of a Regular ExpressionThere are three important parts to a regular expression. Anchors are used to specify the position of the pattern in relation to a line oftext.Character Sets match one or more characters in a single position.Modifiers specify how many times the previous character set is repeated.A simple example that demonstrates all three parts is the regularexpression\"^#*\". The up arrow is an anchor that indicates the beginning of the line. The character \"#\" is a simple character set that matches thesingle character\"#\". The asterisk is a modifier.In a regular expression it specifies that the previous character setcan appear any number of times, including zero.This is a useless regular expression, as you will see shortly.There are also two types of regular expressions: the\"Basic\" regular expression, and the\"extended\" regular expression.A few utilities likeawk andegrep use the extended expression.Most use the \"basic\" regular expression.From now on, if I talk about a \"regular expression,\" it describes a feature in both types.Here is a table of the Solaris (around 1991) commands that allow you to specify regularexpressions:UtilityRegular Expression TypeviBasic sedBasic grepBasic csplitBasic dbxBasic dbxtoolBasic moreBasic edBasic exprBasic lexBasic pgBasic nlBasic rdistBasic awkExtended nawkExtended egrepExtendedEMACSEMACS Regular ExpressionsPERLPERL Regular ExpressionsThe Anchor Characters: ^ and $Most UNIX text facilities are line oriented. Searching for patternsthat span several lines is not easy to do.You see, the end of line character is not included in the block oftext that is searched.It is a separator.Regular expressions examine the text between the separators.If you want to search for a pattern that is at one end or the other,you useanchors. The character\"^\" is the starting anchor, and the character\"$\" is the end anchor.The regular expression\"^A\" will match all lines that start with a capital A.The expression\"A$\" will match all lines that end with the capital A.If the anchor characters are not used at the proper end of thepattern, then they no longer act as anchors.That is, the \"^\" is only an anchor if it is the first character in a regularexpression.The\"$\" is only an anchor if it is the last character.The expression\"$1\" does not have an anchor.Neither does\"1^\". If you need to match a\"^\" at the beginning of the line, or a\"$\" at the end of a line, you must escape the special characters with a backslash.Here is a summary:PatternMatches^A\"A\" at the beginning of a lineA$\"A\" at the end of a lineA^\"A^\" anywhere on a line$A\"$A\" anywhere on a line^^\"^\" at the beginning of a line$$\"$\" at the end of a lineThe use of\"^\" and\"$\" as indicators of the beginning or end of a line is a conventionother utilities use.Thevi editor uses these two characters as commands to go to the beginning orend of a line.The C shell uses\"!^\" to specify the first argument of the previous line, and\"!$\" is the last argument on the previous line.It is one of those choices that other utilities go along with tomaintain consistency.For instance,\"$\" can refer to the last line of a file when usinged andsed. Cat -e marks end of lines with a\"$\". You might see it in other programs as well.Matching a character with a character setThe simplest character set is a character.The regular expression\"the\" contains three character sets:\"t,\" \"h\" and \"e\". It will match any line with the string\"the\" inside it. This would also match the word\"other\". To prevent this, put spaces before and after the pattern:\" the \". You can combine the string with an anchor.The pattern\"^From: \" will match the lines of a mail message that identify the sender.Use this pattern with grep to print every address in your incoming mail box:grep '^From: ' /usr/spool/mail/$USERSome characters have a special meaning in regular expressions.If you want to search for such a character, escape it with a backslash.Match any character with .The character\".\" is one of those special meta-characters. By itself it will match any character, except the end-of-linecharacter.The pattern that will match a line with a single characters is^.$Specifying a Range of Characters with [...]If you want to match specific characters, you can use the squarebrackets to identify the exact characters you are searching for.The pattern that will match any line of text that contains exactly onenumber is^[0123456789]$This is verbose.You can use the hyphen between two characters to specify a range:^[0-9]$You can intermix explicit characters with character ranges.This pattern will match a single character that is a letter, number,or underscore:[A-Za-z0-9_]Character sets can be combined by placing them next to each other.If you wanted to search for a word thatStarted with a capital letter \"T\".Was the first word on a lineThe second letter was a lower case letterWas exactly three letters long, andThe third letter was a vowelthe regular expression would be\"^T[a-z][aeiou] \".Exceptions in a character setYou can easily search for all characters except those in squarebrackets by putting a\"^\" as the first character after the \"[\". To match all characters except vowels use\"[^aeiou]\". Like the anchors in places that can't be considered an anchor, thecharacters\"]\" and\"-\" do not have a special meaning if they directly follow\"[\". Here are some examples:Regular ExpressionMatches[]The characters \"[]\"[0]The character \"0\"[0-9]Any number[^0-9]Any character other than a number[-0-9]Any number or a \"-\"[0-9-]Any number or a \"-\"[^-0-9]Any character except a number or a \"-\"[]0-9]Any number or a \"]\"[0-9]]Any number followed by a \"]\"[0-9-z]Any number, or any character between \"9\" and \"z\".[0-9\\-a\\]]Any number, ora \"-\", a \"a\", or a \"]\"Repeating character sets with *The third part of a regular expression is the modifier.It is used to specify how may times you expect to see the previouscharacter set. The special character\"*\" matcheszero or more copies.That is, the regular expression\"0*\" matches zero or more zeros, while the expression\"[0-9]*\" matches zero or more numbers.This explains why the pattern\"^#*\" is useless, as it matches any number of \"#'s\" at the beginning of the line, including zero. Therefore this will match every line, because every line starts withzero or more \"#'s\". At first glance, it might seem that starting the count at zero isstupid.Not so.Looking for an unknown number of characters is very important.Suppose you wanted to look for a number at the beginning of a line,and there may or may not be spaces before the number. Just use\"^ *\" to match zero or more spaces at the beginning