Question

Write a PHP regular expression pattern that matches a string that satisfies the following description: The...

Write a PHP regular expression pattern that matches a string that satisfies the following description:
The string must begin with the (uppercase) letter A. Any three alphanumeric characters
must follow. After these, the letter B (uppercase or lowercase) must be repeated one or more times,
and the string must end with two digits.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER :

$pattern = "A[\w]{3}[bB]{1,}[0-9]{2}"

A means it matches the character A literally(case sensitive)

[\w]{3} -> {3} is a quantifier means that the preceding word(or characters) matches exactly 3 times
[\w] matches any word character (equal to [a-zA-Z0-9_])

[bB]{1,} -> {1} is a quantifier that matches between one and unlimited times(as many times as possible)
[bB] matches a single character in the list bB (case sensitive)

[0-9]{2} -> {2} is a quantifier means that the preceding word(or characters) matches or must come exactly 2 times
[0-9] Matches a single digit between 0 and 9

Hope it helps... thank you:)

Add a comment
Know the answer?
Add Answer to:
Write a PHP regular expression pattern that matches a string that satisfies the following description: The...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use the Python “re” module to do the following: 1. Write a regular expression pattern that matche...

    Use the Python “re” module to do the following: 1. Write a regular expression pattern that matches string “March 1, 2019, Mar 1, 2019, March First, 2019, March First, 19”. No credit for not using special characters: “*,+,?, | and etc” to do the matching. 2. Write a regular expression pattern that matches strings representing trains. A single letter stands for each kind of car in a train: Engine, Caboose, Boxcar, Passenger car, and Dining car. There are four rules...

  • Write a regular expression that matches: a) all strings that end with a dot character ".",...

    Write a regular expression that matches: a) all strings that end with a dot character ".", without the quotes. b) all strings that begin with a "#" character, without the quotes. c) all floating-point numbers using standard notation (e.g., 12.345 or –12.345). Note that matching numbers may contain any number of digits before or after the decimal point. d) all floating-point numbers using scientific notation (e.g., 1.234e+5 or –1.234E–5). Again, matching numbers may contain any number of digits before or...

  • Write a regular expression that matches whole numbers, such as 34, and 8, as well as...

    Write a regular expression that matches whole numbers, such as 34, and 8, as well as real numbers with two decimal digits, such as 100.99 and 3.56. Your regular expression will not match numbers with one decimal digits, such as 3.4 or more than two decimal digits, such as 3.555. Answer:

  • I. Write a regular expression that matches a string of bits only if: it starts with...

    I. Write a regular expression that matches a string of bits only if: it starts with a '0', ends with a '00', and has a '1' between every '010'.

  • 10. replaceSubstring Function Write a function named replaceSubstring. The function should accept three C-string or string...

    10. replaceSubstring Function Write a function named replaceSubstring. The function should accept three C-string or string object arguments. Let's call them string1, string2, and string3. It should search string for all occurrences of string2. When it finds an occurrence of Programming Challenges string2, it should replace it with string. For example, suppose the three arguments have the following values: stringt: "the dog jumped over the fence" string 2 "the" string3: "that" With these three arguments, the function would return a...

  • Preliminaries For this lab you will be working with regular expressions in Python. Various functions for...

    Preliminaries For this lab you will be working with regular expressions in Python. Various functions for working with regular expressions are available in the re module. Fortunately, Python makes it pretty easy to check if a string matches a particular pattern. At the top of the file we must import the re module: import re Then we can use the search() function to test whether a string matches a pattern. In the example below, the regular expression has been saved...

  • 5. Describe informally the kind of pattern that matches the following extended regular expression: [b-d]a?e+ and...

    5. Describe informally the kind of pattern that matches the following extended regular expression: [b-d]a?e+ and rewrite it using only the basic (not extended) features of formal regular expressions. [For example, character classes [.1 positive closures +, and optionals? are not basic features, and should be expressed using only the basic taxonomy instead]. [4 marks 6. Explain the assertion that " there is more to taking Compiler Construction course than solely at writing a typical compiler" aiming [3 marks 5....

  • 4. Write regular expressions that match the descriptions given below. (10 P Description A sequence of...

    4. Write regular expressions that match the descriptions given below. (10 P Description A sequence of digits of any length that also contains the sequence of four letters "meow", in that order, anywhere in the Expression sequence. A sequence of zero or more x's and y's, OR zero or one z's. 3 The American word color, or the British spelling (colour). Your answer can NOT include an or. 4 A string that begins with an X and ends with an...

  • Write an LC-3 program (starting at memory location 0x3000) to take a string as input and...

    Write an LC-3 program (starting at memory location 0x3000) to take a string as input and then output information about this string. The end of the string will be denoted with the "#" character. Once the "#" has been found, output the following in order: 1) The letter “u” followed by the number of uppercase letters in the string (A-Z) 2) The letter “l” followed by the number of lowercase letters in the string (a-z) 3) The letter “n” followed...

  • 7-8 Linux based questions. Thanks! 7. Which of the following best describes the regular expression. +?...

    7-8 Linux based questions. Thanks! 7. Which of the following best describes the regular expression. +? a. Any single character b. Any single character followed by an asterisk c. Any single character repeated any number of times d. Any single character repeated at least one time e. Any list of characters as long as there is at least one character 8. True/false: The regular expression. will only match any single character that appears three times.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT