Arnab Chakraborty has Published 32 Articles

Regex to match lines containing multiple strings in Java

Arnab Chakraborty

Arnab Chakraborty

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

810 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 = ... Read More

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

Arnab Chakraborty

Arnab Chakraborty

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

439 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

Arnab Chakraborty

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

308 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");       // ... Read More

How can I write in order with for loop or while loop?

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Jun-2020 15:34:17

258 Views

Example#include #include void main() {    int i,j,a=0,b=1,n;    clrscr();    printf("****************OUTPUT*****************");    printf("enter the value of n : ");    scanf("%d",&n);    printf(" the required order is: " );    for(i=1;i

How to capture multiple matches in the same line in Java regex

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Jun-2020 10:49:20

3K+ Views

Exampleimport java.util.regex.*; class PatternMatcher {    public static void main(String args[]) {       int count = 0;       // String to be scanned to find the pattern.       String content = "aaa bb aaa";       String string = "aaa";     ... Read More

Java Regular Expression that doesn't contain a certain String.

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Jun-2020 10:34:58

632 Views

Exampleimport java.util.regex.*; class PatternMatch{    public static void main(String args[]) {       String content = "I am a student";       String string = ".*boy.*";       boolean isMatch = Pattern.matches(string, content);       System.out.println("The line contains 'boy'?"+ isMatch);    } }Outputthe line contains 'boy'?falsematches()­­It ... Read More

Operating system time slicing in round robin scheduling

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Jun-2020 09:50:34

366 Views

process Burst time A 4 B 1 C 8 D 1time slice=10 unitA B C D A C C C 0 2 3 5 6 8 10 12 14So A will complete 8 cycles.

Reply to user text using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 16-Jun-2020 08:28:13

2K+ Views

You can solve this problem by using if-elif-else statements. And to make it like, it will ask for a valid option until the given option is on the list, we can use while loops. When the option is valid, then break the loop, otherwise, it will ask for the input ... Read More

Count spaces, uppercase and lowercase in a sentence using C

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Jan-2020 12:45:05

857 Views

#include int main() {    char str[100],i;    int upper = 0, lower = 0, number = 0, special = 0,whitesp=0;    printf("enter string");    gets(str);    for (i = 0; i < str[i]!='\0'; i++) {       if (str[i] >= 'A' && str[i] = 'a' && str[i] = '0' && str[i]

How to execute Python CGI Script on Apache Server?

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Jul-2019 22:30:22

553 Views

in apache server normally python script will not run. SO you have to go httpd.conf file in apache server, inside that you will find some .php, .asp etc in a property called AddHandler, you have to put there .py. save the file and restart the server. then run your python ... Read More

Advertisements