HTML Strings

View as PDF

Submit solution

Points: 4
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Web developers use HTML tags in angle brackets to format the text on web pages.

Check whether a given string starts with an apparent HTML tag (a series of characters in angle brackets) and ends with a matching closing HTML tag (the same sequence preceded by the / character, all in angle brackets). If yes, the method removes both tags and returns the result; otherwise the method returns the original string unchanged. Look at the sample for an example.

Input Specification

The first and only line of input will contain a sequence of no greater than 1000 ASCII characters.

Output Specification

If the string is bounded by an HTML tag, then output the string without the tags. If it is not bounded by an HTML tag, then just output the original string.

Sample Input 1

<h1>Strings are immutable</h1>

Sample Output 1

Strings are immutable

Sample Input 2

<b>Jonathan please help me with uploading these problems, thanks.

Sample Output 2

<b>Jonathan please help me with uploading these problems, thanks.

Comments


  • 1
    pbenum  commented on Nov. 26, 2020, 9:40 a.m.

    For case #9, there is a leading space in the input. Notice the problem description instructs to remove HTML tags only if the input starts with one.