Question: Write regular expressions in Java for the following: Strings between10and20characters (inclusive) which have odd lengths. The allowed characters here are not specified, and should be

Write regular expressions in Java for the following:

  1. Strings between10and20characters (inclusive) which have odd lengths.
    • The allowed characters here arenotspecified, and should be considered unrestricted
    • Examples:automobiles,i<3pancakes13
    • Non-Examples:5five,i<3pancakes14!
  2. A list of comma-separated, characters surrounded by square brackets[]. Recall, a character is denoted by single quotes surrounding it. An optional single space character is allowed after the comma.
    • The number of characters in the list isnotspecified, so an empty list ([])isallowed.
    • The term comma-separated implies that a trailing comma (['a', 'b', 'c',])is notallowed.
    • The single space character does not need to be consistent, so mixed spaces (['a','b', 'c'])isallowed
    • Examples:['a'],['a','b','c']
    • Non-Examples:'a','b','c',['a' 'b' 'c']
  3. A decimal number (two integer values, where both integers are present, separated by a decimal point). The left most digit on the lefthand side of decimal point must be non-zero (i.e., there are no leading zeros) unless the only digit to the left of the decimal point is a zero. Trailing zeros are allowed. An optional sign-is allowed, prefixing the decimal as negative.
    • Examples:10100.001,-1.0
    • Non-Examples:1,.5
  4. A double-quoted string literal. Escape characters are supported starting with a backslash (\), followed by one ofbnrt'"\.
    • Remember to escape things in Java! The input"1\t2"is the string literal"\"1\\t2\"". You need to be understand this well as it will occur frequently throughout this course.
    • Examples:"","Hello, World!","1\t2"
    • Non-Examples:"unterminated,"invalid\escape"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

1 Regular expression for strings between 10 and 20 characters inclusive with odd lengths java 1020 E... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!