Role of Matcher.group() Method in Java Regular Expressions

Jai Janardhan
Updated on 30-Jul-2019 22:30:24

672 Views

The method java.time.Matcher.group() is used to find the subsequence in the input sequence string that is a match to the required pattern. This method returns the subsequence that is matched by the previous match which can even be empty.A program that demonstrates the method Matcher.group() 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[]) { Pattern p = Pattern.compile("\w\d"); Matcher m = p.matcher("This is gr8"); System.out.println("The input ... Read More

Order Timestamp Values in Ascending Order in MySQL

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

209 Views

You can use ORDER BY ASC to order timestamp values in ascending order.The following is the syntax without using TIMESTAMP() −SELECT yourTimestampColumnName from yourTableName order by yourTimestampColumnName ASC;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table Timestamp_TableDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> yourTimestamp timestamp -> ); Query OK, 0 rows affected (0.83 sec)Now you can insert some records in the table using insert command. The query is as follows ... Read More

Return Date Set to Last Millisecond of the Minute in Java

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

81 Views

Let us first set the calendar object −Calendar calendar = Calendar.getInstance();Use the getMaximum() method in Java to returns the maximum value for the given calendar field. We will use it to set the minute, second and milliseconds.For seconds −calendar.set(Calendar.SECOND, calendar.getMaximum(Calendar.SECOND));For milliseconds −calendar.set(Calendar.MILLISECOND, calendar.getMaximum(Calendar.MILLISECOND));The following is an example that returns a Date set to the last possible millisecond of the minute −Example Live Demoimport java.util.Calendar; import java.util.GregorianCalendar; public class Demo {    public static void main(String[] argv) throws Exception {       Calendar calendar = Calendar.getInstance();       // seconds       calendar.set(Calendar.SECOND, calendar.getMaximum(Calendar.SECOND));       // milliseconds ... Read More

Working of a Turbojet Engine

Shanmukh Pasumarthy
Updated on 30-Jul-2019 22:30:24

2K+ Views

A turbojet engine is used in Aircraft. These are air-breathing engines which suck in air from the atmosphere for combustion. It has various components like inlet, compressor, combustion chamber, turbines, and nozzle. Air is drawn into the turbojet engine, compressed, mixed with fuel, and burned continuously.The exhaust product of this burning operates the turbine for the compressor, producing thrust which propels the aircraft. Turboprops are used in smaller and slow-paced air crafts as turbojets are not efficient at low speeds whereas turbofans have better specific fuel consumption than the turbojet. These engines are generally installed below the wings or near ... Read More

8085 Program to Check Even or Odd Number

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

10K+ Views

In this program we will see how to check whether a number is odd or even.Problem StatementWrite 8085 Assembly language program to check whether a number is odd or even.DiscussionThe Odd Even checking is very simple. we can determine one number is odd or even by checking only the LSb. When LSb is 1, the number is odd, otherwise it is even.In this program we are taking a number from memory and then ANDing 01H with it. if the result is nonzero, then the number is odd,  otherwise it is even.Inputfirst inputAddressData......800015......second inputAddressData......80002C......Flow DiagramProgramAddressHEX CodesLabelMnemonicsCommentsF0003A, 00, 80LDA 8000HLoad the number ... Read More

Switch Between Hide and View Password in Android

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

1K+ Views

There are so many cases, it required to show password while entering password or after entered password. This example demonstrate about How to switch between hide and view password.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.                                                 In the above code we have given two TextInputEditText ... Read More

Generate Byte Code File in Python

Samual Sam
Updated on 30-Jul-2019 22:30:24

1K+ Views

All python program automatically compiles your source code to compile code also called as byte code, before executing it.Whenever we import a module for the first time or when your source file is a new file or we have an updated file then the recently compiled file, a .pyc file will be created on compiling the file in the same directory as the .py file (from python 3- you might see .pyc file is in a subdirectory called __pycache__ instead in the same directory as your .py file). This is a time-saver mechanism as it prevents python to skip the ... Read More

Use IFNULL with MySQL ORDER BY

Samual Sam
Updated on 30-Jul-2019 22:30:24

378 Views

You can use IFNULL along with ORDER BY clause. The syntax is as follows −SELECT *FROM yourTableName ORDER BY IFNULL(yourColumnName1, yourColumnName2);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table IfNullDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> ProductName varchar(10),    -> ProductWholePrice float,    -> ProductRetailPrice float,    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (1.19 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into IfNullDemo(ProductName, ProductWholePrice, ProductRetailPrice) values('Product-1', 99.50, ... Read More

Get Operating System Temporary Directory in Java

Samual Sam
Updated on 30-Jul-2019 22:30:24

1K+ Views

To get the temporary directory in Java, use the System.getProperty() method. Use theIt’s syntax is −String getProperty(String key)Above, the key is the name of the system property. Since, we want the Java Home Directory name, therefore we will add the key as −java.io.tmpdirThe following is an example −Example Live Demopublic class Demo { public static void main(String []args){ String strTmp = System.getProperty("java.io.tmpdir"); System.out.println("OS current temporary directory: " + strTmp); System.out.println("OS Name: " + System.getProperty("os.name")); ... Read More

Count Number of Rows in Each Table in MySQL

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

3K+ Views

To get the count of rows, you need to use information_schema.tables. The syntax is as follows.SELECT table_name, table_rows FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ‘yourDatabaseName’;Let us implement the above syntax for a database with the name ‘test’. The query is as follows displaying the table names with the count of rows in the table.mysql> SELECT table_name, table_rows -> FROM INFORMATION_SCHEMA.TABLES -> WHERE TABLE_SCHEMA = 'test';The following is the output.+------------------------------------+------------+ | TABLE_NAME | TABLE_ROWS | +------------------------------------+------------+ | _student_trackerdemo | 0 | | _studenttrackerdemo | 0 | | add30minutesdemo | 0 | | addcolumn | 0 | ... Read More

Advertisements