Matcher Pattern Method in Java Regular Expressions

Vikyath Ram
Updated on 30-Jun-2020 08:05:47

163 Views

The method java.time.Matcher.pattern() returns the pattern that is matched upon by the Matcher. This method accepts no parameters.A program that demonstrates the method Matcher.pattern() in Java regular expressions is given as follows −Example Live Demoimport java.util.regex.Matcher; import java.util.regex.Pattern; public class Demo {    public static void main(String args[]) {       String regex = "Apple";       Pattern p = Pattern.compile(regex);       Matcher m = p.matcher("AppleIsAFruit");       System.out.println("Pattern: " + m.pattern());    } }The output of the above program is as follows −Pattern: AppleNow let us understand the above program.The pattern that is matched upon ... Read More

Set the Color of the Right Border Using CSS

varma
Updated on 30-Jun-2020 08:05:22

74 Views

To set the color of the right border, use the border-right-color property. You can try to run the following code to implement border-color-property −ExampleLive Demo                    p {             border-style: dotted;             border-right-color: #FFFF00;          }                     This is demo text.     Output

Print a Vector in Comma-Delimited List in Java

Arushi
Updated on 30-Jun-2020 08:04:49

527 Views

A Vector can be printed in a comma-delimited list, in index order and surrounded by square brackets ([]) by simply using System.out.println() along with the Vector object.A program that demonstrates this is given as follows −Example Live Demoimport java.util.Vector; public class Demo {    public static void main(String args[]) {       Vector vec = new Vector(5);       vec.add(4);       vec.add(1);       vec.add(3);       vec.add(9);       vec.add(6);       System.out.println(vec);    } }The output of the above program is as follows −[4, 1, 3, 9, 6]Now let us understand ... Read More

Concatenate with Condition in MongoDB

AmitDiwan
Updated on 30-Jun-2020 08:04:42

424 Views

To concatenate with condition in MongoDB, use $cond and in that, work with $concat. Let us create a collection with documents −> db.demo745.insertOne({Value1:"100", Value2:"100"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5eae6419a930c785c834e554") } > db.demo745.insertOne({Value1:"40", Value2:"50"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5eae6421a930c785c834e555") } > db.demo745.insertOne({Value1:"13", Value2:"45"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5eae6429a930c785c834e556") }Display all documents from a collection with the help of find() method −> db.demo745.find();This will produce the following output −{ "_id" : ObjectId("5eae6419a930c785c834e554"), "Value1" : "100", "Value2" : "100" } { "_id" : ObjectId("5eae6421a930c785c834e555"), "Value1" : "40", "Value2" : "50" } ... Read More

Set Min Height and Max Height of an Element Using CSS

varun
Updated on 30-Jun-2020 08:03:54

306 Views

To set min-height and max-height of an element using CSS, you can try to run the following code −ExampleLive Demo                    div {             max-height: 550px;             min-height: 450px;             background-color: red;          }                     Below is a div with maximum and minimum height. Resize the web browser to see the effect.       This is demo text. This is demo text. This is demo text.          This is demo text. This is demo text. This is demo text.          This is demo text. This is demo text. This is demo text.          

Clear Out All of the Vector Elements in Java

Jai Janardhan
Updated on 30-Jun-2020 08:03:52

444 Views

A Vector can be cleared in Java using the method java.util.Vector.clear(). This method removes all the elements in the Vector. There are no parameters required by the Vector.clear() method and it returns no value.A program that demonstrates this is given as follows −Example Live Demoimport java.util.Vector; public class Demo {    public static void main(String args[]) {       Vector vec = new Vector(5);       vec.add(4);       vec.add(1);       vec.add(3);       vec.add(9);       vec.add(6);       vec.add(2);       vec.add(8);       System.out.println("The Vector elements are: " ... Read More

Find Element in MongoDB Embedded Document

AmitDiwan
Updated on 30-Jun-2020 08:02:54

188 Views

To find a certain element, use $project in MongoDB. Let us create a collection with documents −> db.demo744.insertOne( ...    { ...       studentInformation: ...       [ ...          { ...             studentName:"Robert", ...             grade:"A" ...          }, ...          { ...             studentName:"Bob", ...             grade:"C" ...          }, ...          { ...             ... Read More

Working with Hex Numbers in MySQL

Chandu yadav
Updated on 30-Jun-2020 08:02:12

468 Views

In order to work with hex, use the CONV() function to convert between bases. The syntax is as follows −SET anyVariableName = CONV(yourHexValue, 16, 10);To understand the above syntax, let us create a stored procedure. The query to create a stored procedure is as follows −mysql> DELIMITER // mysql> CREATE PROCEDURE SP_HEX_TO_DEC( HEXVALUE VARCHAR(10) )    -> BEGIN    -> DECLARE Decimalvalue INTEGER;    -> SET Decimalvalue = CONV(HEXVALUE, 16, 10);    -> select Decimalvalue;    -> END;    -> // Query OK, 0 rows affected (0.19 sec) mysql> DELIMITER ;The above stored procedure converts the hexadecimal to decimal. As ... Read More

Extract Entire Documents Based on Collection Comparison

AmitDiwan
Updated on 30-Jun-2020 08:01:12

130 Views

For this, use $$ROOT in MongoDB. Let us create a collection with documents −> db.demo743.insertOne({id:1, "ShippingDate":"2020-01-21", value:50}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ead893a57bb72a10bcf0680") } > db.demo743.insertOne({id:2, "ShippingDate":"2020-05-10", value:30}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ead893c57bb72a10bcf0681") } > db.demo743.insertOne({id:3, "ShippingDate":"2020-05-10", value:60}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ead894657bb72a10bcf0682") } > db.demo743.insertOne({id:1, "ShippingDate":"2020-05-11", value:75}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ead895657bb72a10bcf0683") }Display all documents from a collection with the help of find() method −> db.demo743.find();This will produce the following output −{ "_id" : ObjectId("5ead893a57bb72a10bcf0680"), "id" : 1, "ShippingDate" : "2020-01-21", "value" : 50 ... Read More

Access Specific Element in MongoDB Array

AmitDiwan
Updated on 30-Jun-2020 07:59:03

2K+ Views

To fetch a specific element, iterate with forEach(). Let us create a collection with documents −> db.demo742.insertOne({ "userDetails": [ { "userName":"Robert", "CountryName":"UK" }, { "userName":"David", "CountryName":"AUS" } ]} ); {    "acknowledged" : true,    "insertedId" : ObjectId("5ead790b57bb72a10bcf0677") }Display all documents from a collection with the help of find() method −> db.demo742.find().pretty();This will produce the following output −{    "_id" : ObjectId("5ead790b57bb72a10bcf0677"),    "userDetails" : [       {          "userName" : "Robert",          "CountryName" : "UK"       },       {          "userName" : "David",   ... Read More

Advertisements