Regex to match lines containing multiple strings in Java

Arnab Chakraborty
Updated on 21-Jun-2020 06:33:07

527 Views

ExampleLive Demoimport java.util.ArrayList; import java.util.List; import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class SearchRegex {    private Pattern subPattern = Pattern.compile(SUBJECT_PATTERN);    private Matcher matcher;    private static final String SUBJECT_PATTERN = "(?s)Subject 1:\s(.*)Subject 2:";    public static void main(String[] args) {       String d = "Subject 1: Java" + "Subject 2: Python";       SearchRegex obj = new SearchRegex();       List list = obj.getSubject(d);       System.out.println("Address Result : " + list);    }    private List getSubject(String d){       List result = new ArrayList();       matcher = subPattern.matcher(d);       while (matcher.find()) {          result.add(matcher.group(1));       }       return result;    } }OutputAddress Result : [Java]

How to match a line not containing a word in Java Regex

Arnab Chakraborty
Updated on 21-Jun-2020 06:31:20

202 Views

ExampleLive Demoimport java.util.regex.Matcher; import java.util.regex.Pattern; public class NoRegTest {    public static void main(String[] args) {       String s="^fun";       Pattern pattern = Pattern.compile(s);       Matcher matcher = pattern.matcher("Java is fun");       if(!matcher.find()) {          System.out.println("not found");       }    } }Outputnot found

How to extract a group from a Java String that contains a Regex pattern

Arnab Chakraborty
Updated on 21-Jun-2020 06:30:13

201 Views

How to extract a group from a Java String that contains a Regex patternimport java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexTest {    public static void main(String[] args) {       Pattern pattern = Pattern.compile("fun");       Matcher matcher = pattern.matcher("Java is fun");       // using Matcher find(), group(), start() and end() methods       while (matcher.find()) {          System.out.println("Found the text \"" + matcher.group()             + "\" starting at " + matcher.start()             + " index and ending at index ... Read More

CSS3 Multi-Column column-span Property

Ankitha Reddy
Updated on 21-Jun-2020 06:28:59

69 Views

The column-span property is used to specify the span between columns. You can try to run the following code to implement column-span property using CSS −Example Live Demo    .multi {       /* Column count property */       -webkit-column-count: 4;       -moz-column-count: 4;       column-count: 4;       /* Column gap property */       -webkit-column-gap: 40px;       -moz-column-gap: 40px;       column-gap: 40px;       /* Column style property */       column-rule-style: solid;       column-rule-color: #ff00ff;   ... Read More

CSS3 Multi-Column rule-color Property

vanithasree
Updated on 21-Jun-2020 06:26:24

51 Views

The multi-column rule-color property is used to specify the column rule color. You can try to run the following code to implement a rule-color property in CSS3 −ExampleLive Demo                    .multi {             /* Column count property */             -webkit-column-count: 4;             -moz-column-count: 4;             column-count: 4;                         /* Column gap property */             -webkit-column-gap: ... Read More

CSS3 Multi-Column column-gap Property

George John
Updated on 21-Jun-2020 06:23:17

71 Views

The multi-column column-gap property is used to decide the gap between the columns.ExampleYou can try to run the following code to implement column-gap propertyLive Demo                    .multi {             /* Column count property */             -webkit-column-count: 4;             -moz-column-count: 4;             column-count: 4;                         /* Column gap property */             -webkit-column-gap: 40px;       ... Read More

CSS3 Multi-Column column-rule Property

Giri Raju
Updated on 21-Jun-2020 05:35:34

57 Views

The multi-column column-rule property is used to specify the number of rules.You can try to run the following code to implement the column-rule property in CSS3 −ExampleLive Demo                    .multi {             /* Column count property */             -webkit-column-count: 4;             -moz-column-count: 4;             column-count: 4;                         /* Column gap property */             -webkit-column-gap: 40px; ... Read More

Example of key frames with left animation using CSS3

mkotla
Updated on 21-Jun-2020 05:26:43

76 Views

The following example shows height, width, color, name, and duration of animation with keyframes syntax −ExampleLive Demo                    h1 {             -moz-animation-duration: 3s;             -webkit-animation-duration: 3s;             -moz-animation-name: slidein;             -webkit-animation-name: slidein;          }          @-moz-keyframes slidein {             from {                margin-left:100%; width:300%             }             to {                margin-left:0%; width:100%;             }          }          @-webkit-keyframes slidein {             from {                margin-left:100%; width:300%             }             to {                margin-left:0%; width:100%;             }           }                     Tutorials Point       this is an example of moving left animation .       Reload page       function myFunction() { location.reload(); }    

Rotate the element based on an angle using CSS

George John
Updated on 21-Jun-2020 05:14:45

158 Views

Let us learn how to rotate the element based on an angleExampleLive Demo                    div {             width: 300px;             height: 100px;             background-color: pink;             border: 1px solid black;          }          div#myDiv {             /* IE 9 */             -ms-transform: rotate(20deg);                         /* Safari */             -webkit-transform: rotate(20deg);                         /* Standard syntax */             transform: rotate(20deg);          }                              Tutorials point.com.                      Tutorials point.com           Output

Change the height of element using CSS

varma
Updated on 21-Jun-2020 05:05:59

158 Views

Use the scaleY() method to change the height of the element with CSS.Let us see the syntax −scaleY(n);Here, n is a number representing the scaling factor.Let us see an example −div {    width: 40px;    height: 50px;    background-color: black; } .myScaled {    transform: scaleY(0.9);    background-color: orange; }

Advertisements