title-img


Valid Username Regular Expression Java

You are updating the username policy on your company's internal networking platform. According to the policy, a username is considered valid if all the following constraints are satisfied: The username consists of 8 to 30 characters inclusive. If the username consists of less than or greater than characters, then it is an invalid username. The username can only contain alphanumeric characters and underscores (_). Alphanumeric characters describe the character set consisting of lowercase

View Solution →

Tag Content Extractor Java

In a tag-based language like XML or HTML, contents are enclosed between a start tag and an end tag like <tag>contents</tag>. Note that the corresponding end tag starts with a /. Given a string of text in a tag-based language, parse this text and retrieve the contents enclosed within sequences of well-organized tags meeting the following criterion: 1.The name of the start and end tags must be same. The HTML code <h1>Hello World</h2> is not valid, because the text starts with an h1 tag and e

View Solution →

Attribute Parser C++

This challenge works with a custom-designed markup language HRML. In HRML, each element consists of a starting and ending tag, and there are attributes associated with each tag. Only starting tags can have attributes. We can call an attribute by referencing the tag, followed by a tilde, '~' and the name of the attribute. The tags may also be nested. The opening tags follow the format: <tag-name attribute1-name = "value1" attribute2-name = "value2" ...> The closing tags follow the format

View Solution →

StringStream C++

In this challenge, we work with string streams. stringstream is a stream class to operate on strings. It implements input/output operations on memory (string) based streams. stringstream can be helpful in different type of parsing. The following operators/functions are commonly used here Operator >> Extracts formatted data. Operator << Inserts formatted data. Method str() Gets the contents of underlying string device object. Method str(string) Sets the contents of underl

View Solution →

Strings C++

C++ provides a nice alternative data type to manipulate strings, and the data type is conveniently called string. Some of its widely used features are the following: Declaration: string a = "abc"; Size: int len = a.size(); Concatenate two strings: string a = "abc"; string b = "def"; string c = a + b; // c = "abcdef". Accessing i th element: string s = "abc"; char c0 = s[0]; // c0 = 'a' char c1 = s[1]; // c1 = 'b'

View Solution →