Find Capital Letters with Regex in MySQL

Chandu yadav
Updated on 30-Jul-2019 22:30:25

512 Views

You can use REGEXP BINARY for thisselect *from yourTableName where yourColumnName REGEXP BINARY '[A-Z]{2}';Let us first create a tablemysql> create table FindCapitalLettrsDemo    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentFirstName varchar(20)    -> ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into FindCapitalLettrsDemo(StudentFirstName) values('JOHN'); Query OK, 1 row affected (0.24 sec) mysql> insert into FindCapitalLettrsDemo(StudentFirstName) values('Carol'); Query OK, 1 row affected (0.15 sec) mysql> insert into FindCapitalLettrsDemo(StudentFirstName) values('bob'); Query OK, 1 row affected (0.14 sec) mysql> insert into ... Read More

DoubleStream Average Method in Java

Krantik Chavan
Updated on 30-Jul-2019 22:30:25

2K+ Views

The average() method of the DoubleStream class in Java returns an OptionalDouble which is the arithmetic mean of elements of this stream. If the stream is empty, empty is returned.The syntax is as follows:OptionalDouble average()Here, OptionalDouble is a container object which may or may not contain a double value.To use the DoubleStream class in Java, import the following package:import java.util.stream.DoubleStream;First, create DoubleStream and add some elements:DoubleStream doubleStream = DoubleStream.of(50.8, 35.7, 49.5, 12.7, 89.7, 97.4);Get the average of the elements of the stream:OptionalDouble res = doubleStream.average();The following is an example to implement DoubleStream average() method in Java:Example Live Demoimport java.util.*; import java.util.stream.DoubleStream; ... Read More

Linear Regression Using Python

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

779 Views

Linear regression is one of the simplest standard tool in machine learning to indicate if there is a positive or negative relationship between two variables.Linear regression is one of the few good tools for quick predictive analysis. In this section we are going to use python pandas package to load data and then estimate, interpret and visualize linear regression models.Before we go down further down, let’s discuss what is regression first?What is Regression?Regression is a form of predictive modelling technique which helps in creating a relationship between a dependent and independent variable.Types of RegressionLinear RegressionLogistic RegressionPolynomial RegressionStepwise RegressionWhere is Linear ... Read More

Find Two Random Documents in a MongoDB Collection

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

207 Views

Let us first create a collection and add some documents to it> db.twoRandomDocumentDemo.insertOne({"StudentId":10}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9ec9aad628fa4220163b87") } > db.twoRandomDocumentDemo.insertOne({"StudentId":100}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9ec9add628fa4220163b88") } > db.twoRandomDocumentDemo.insertOne({"StudentId":45}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9ec9b0d628fa4220163b89") } > db.twoRandomDocumentDemo.insertOne({"StudentId":55}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9ec9b3d628fa4220163b8a") } > db.twoRandomDocumentDemo.insertOne({"StudentId":5}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9ec9b7d628fa4220163b8b") } > db.twoRandomDocumentDemo.insertOne({"StudentId":7}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9ec9bad628fa4220163b8c") }Following is the query to display all documents from a collection with the help of find() method> db.twoRandomDocumentDemo.find();This ... Read More

Find Strings Beginning with a Number Using MySQL Regex

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

398 Views

To find strings beginning with a number, use Regular Expressions. Let us first create a table −mysql> create table DemoTable (    Id varchar(200) ); Query OK, 0 rows affected (0.59 sec)Insert records in the table using insert command −mysql> insert into DemoTable values('123User'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values('_$123User'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values('User123456'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('0000User'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values('&^*User'); Query OK, 1 row affected (0.24 sec)Display records ... Read More

CharBuffer compareTo Method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

130 Views

A buffer can be compared with another buffer using the method compareTo() in the class java.nio.CharBuffer. This method returns a negative integer if the buffer is less than the given buffer, zero if the buffer is equal to the given buffer and a positive integer if the buffer is greater than the given buffer.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo { public static void main(String[] args) {    int n = 5;    try {       CharBuffer buffer1 = CharBuffer.allocate(n);       buffer1.put('A');       buffer1.put('P'); ... Read More

Convert String to Date in MongoDB

Nancy Den
Updated on 30-Jul-2019 22:30:25

1K+ Views

To convert the string to date in MongoDB, use the following syntax:db.yourCollectionName.aggregate(    [       {          $project:          {             anyVariableName:             {                $dateFromString:                {                   dateString: '$yourFieldName’                }             }          }       }    ] );To understand the above syntax, ... Read More

What is an Application Object in JSP

George John
Updated on 30-Jul-2019 22:30:25

416 Views

The application object is direct wrapper around the ServletContext object for the generated Servlet and in reality an instance of a javax.servlet.ServletContext object.This object is a representation of the JSP page through its entire lifecycle. This object is created when the JSP page is initialized and will be removed when the JSP page is removed by the jspDestroy() method.By adding an attribute to application, you can ensure that all JSP files that make up your web application have access to it.

LocalTime getMinute Method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

185 Views

The minute of the hour for a particular LocalTime can be obtained using the getMinute() method in the LocalTime class in Java. This method requires no parameters and it returns the minute of the hour in the range of 0 to 59.A program that demonstrates this is given as followsExample Live Demoimport java.time.*; public class Demo {    public static void main(String[] args) {       LocalTime lt = LocalTime.parse("23:15:30");       System.out.println("The LocalTime is: " + lt);       System.out.println("The minute is: " + lt.getMinute());    } }outputThe LocalTime is: 23:15:30 The minute is: 15Now let us ... Read More

Period minusDays Method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

158 Views

An immutable copy of the Period object where some days are subtracted from it can be obtained using the minusDays() method in the Period class in Java. This method requires a single parameter i.e. the number of days to be subtracted and it returns the Period object with the subtracted days.A program that demonstrates this is given as follows:Example Live Demoimport java.time.Period; public class Demo {    public static void main(String[] args) {       String period = "P5Y7M15D";       Period p1 = Period.parse(period);       System.out.println("The Period is: " + p1);       Period p2 ... Read More

Advertisements